Skip to content

Commit

Permalink
fix(api): rebased
Browse files Browse the repository at this point in the history
  • Loading branch information
lennartkloock committed Oct 16, 2023
1 parent d5f2d04 commit 4ee5a2e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
2 changes: 1 addition & 1 deletion platform/api/src/api/v1/gql/guards/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub async fn auth_guard<T>(
) -> Result<T> {
let request_context = ctx.get_req_context();

let auth = request_context.auth().await;
let auth = request_context.auth().await?;

if let Some(auth) = auth {
if Ulid::from(auth.session.user_id) == user_id
Expand Down
16 changes: 1 addition & 15 deletions platform/api/src/api/v1/gql/models/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,7 @@ impl User {
}

async fn totp_enabled(&self, ctx: &Context<'_>) -> Result<bool> {
let request_context = ctx.get_req_context();
let auth = request_context.auth().await?;

if let Some(auth) = auth {
if Ulid::from(auth.session.user_id) == *self.id
|| auth.user_permissions.has_permission(RolePermission::Admin)
{
return Ok(self.totp_enabled_);
}
}

Err(GqlError::Unauthorized {
field: "totpEnabled",
}
.into())
auth_guard(ctx, "totpEnabled", self.totp_enabled_, self.id.into()).await
}
}

Expand Down

0 comments on commit 4ee5a2e

Please sign in to comment.