parent
305b3f913b
commit
870638cbbf
|
|
@ -17,15 +17,15 @@ type Mutation {
|
||||||
deleteInvitation(id: Int!): Int!
|
deleteInvitation(id: Int!): Int!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type VerifyTokenResponse {
|
||||||
|
claims: Claims!
|
||||||
|
}
|
||||||
|
|
||||||
type UserInfo {
|
type UserInfo {
|
||||||
email: String!
|
email: String!
|
||||||
isAdmin: Boolean!
|
isAdmin: Boolean!
|
||||||
}
|
}
|
||||||
|
|
||||||
type VerifyTokenResponse {
|
|
||||||
claims: Claims!
|
|
||||||
}
|
|
||||||
|
|
||||||
type Claims {
|
type Claims {
|
||||||
exp: Float!
|
exp: Float!
|
||||||
iat: Float!
|
iat: Float!
|
||||||
|
|
@ -37,6 +37,7 @@ type Query {
|
||||||
registrationToken: String!
|
registrationToken: String!
|
||||||
isAdminInitialized: Boolean!
|
isAdminInitialized: Boolean!
|
||||||
invitations: [Invitation!]!
|
invitations: [Invitation!]!
|
||||||
|
me: UserInfo!
|
||||||
}
|
}
|
||||||
|
|
||||||
type Invitation {
|
type Invitation {
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ impl VerifyTokenResponse {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, PartialEq, Serialize, Deserialize, GraphQLObject)]
|
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, GraphQLObject)]
|
||||||
pub struct UserInfo {
|
pub struct UserInfo {
|
||||||
email: String,
|
email: String,
|
||||||
is_admin: bool,
|
is_admin: bool,
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ use self::{
|
||||||
worker::WorkerService,
|
worker::WorkerService,
|
||||||
};
|
};
|
||||||
use crate::schema::{
|
use crate::schema::{
|
||||||
auth::{RegisterResponse, TokenAuthResponse, VerifyTokenResponse},
|
auth::{RegisterResponse, TokenAuthResponse, UserInfo, VerifyTokenResponse},
|
||||||
worker::Worker,
|
worker::Worker,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -91,6 +91,13 @@ impl Query {
|
||||||
"Only admin is able to query invitations",
|
"Only admin is able to query invitations",
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn me(ctx: &Context) -> Result<UserInfo> {
|
||||||
|
if let Some(claims) = &ctx.claims {
|
||||||
|
return Ok(claims.user_info().to_owned());
|
||||||
|
}
|
||||||
|
Err(CoreError::Unauthorized("Not logged in"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ lazy_static! {
|
||||||
);
|
);
|
||||||
"#
|
"#
|
||||||
)
|
)
|
||||||
.down("DROP TABLE registeration_token"),
|
.down("DROP TABLE registration_token"),
|
||||||
M::up(
|
M::up(
|
||||||
r#"
|
r#"
|
||||||
CREATE TABLE users (
|
CREATE TABLE users (
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue