parent
305b3f913b
commit
870638cbbf
|
|
@ -17,15 +17,15 @@ type Mutation {
|
|||
deleteInvitation(id: Int!): Int!
|
||||
}
|
||||
|
||||
type VerifyTokenResponse {
|
||||
claims: Claims!
|
||||
}
|
||||
|
||||
type UserInfo {
|
||||
email: String!
|
||||
isAdmin: Boolean!
|
||||
}
|
||||
|
||||
type VerifyTokenResponse {
|
||||
claims: Claims!
|
||||
}
|
||||
|
||||
type Claims {
|
||||
exp: Float!
|
||||
iat: Float!
|
||||
|
|
@ -37,6 +37,7 @@ type Query {
|
|||
registrationToken: String!
|
||||
isAdminInitialized: Boolean!
|
||||
invitations: [Invitation!]!
|
||||
me: UserInfo!
|
||||
}
|
||||
|
||||
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 {
|
||||
email: String,
|
||||
is_admin: bool,
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use self::{
|
|||
worker::WorkerService,
|
||||
};
|
||||
use crate::schema::{
|
||||
auth::{RegisterResponse, TokenAuthResponse, VerifyTokenResponse},
|
||||
auth::{RegisterResponse, TokenAuthResponse, UserInfo, VerifyTokenResponse},
|
||||
worker::Worker,
|
||||
};
|
||||
|
||||
|
|
@ -91,6 +91,13 @@ impl Query {
|
|||
"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)]
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ lazy_static! {
|
|||
);
|
||||
"#
|
||||
)
|
||||
.down("DROP TABLE registeration_token"),
|
||||
.down("DROP TABLE registration_token"),
|
||||
M::up(
|
||||
r#"
|
||||
CREATE TABLE users (
|
||||
|
|
|
|||
Loading…
Reference in New Issue