Skip to content

Commit

Permalink
fixed error renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
KavikaPalletenne committed Jun 28, 2024
1 parent 0e57add commit 0b9f028
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions backend/server/src/models/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ where
let TypedHeader(cookies) = parts
.extract::<TypedHeader<Cookie>>()
.await
.map_err(|_| ChaosError::NotLoggedInError)?;
.map_err(|_| ChaosError::NotLoggedIn)?;

let token = cookies
.get("auth_token")
.ok_or(ChaosError::NotLoggedInError)?;
.ok_or(ChaosError::NotLoggedIn)?;

let claims = decode_auth_token(token, decoding_key, jwt_validator)
.ok_or(ChaosError::NotLoggedInError)?;
.ok_or(ChaosError::NotLoggedIn)?;

Ok(AuthUser {
user_id: claims.sub,
Expand Down Expand Up @@ -85,11 +85,11 @@ where
let TypedHeader(cookies) = parts
.extract::<TypedHeader<Cookie>>()
.await
.map_err(|_| ChaosError::NotLoggedInError)?;
.map_err(|_| ChaosError::NotLoggedIn)?;

let token = cookies
.get("auth_token")
.ok_or(ChaosError::NotLoggedInError)?;
.ok_or(ChaosError::NotLoggedIn)?;

let claims =
decode_auth_token(token, decoding_key, jwt_validator).ok_or(ChaosError::NotLoggedIn)?;
Expand Down Expand Up @@ -128,14 +128,14 @@ where
let TypedHeader(cookies) = parts
.extract::<TypedHeader<Cookie>>()
.await
.map_err(|_| ChaosError::NotLoggedInError)?;
.map_err(|_| ChaosError::NotLoggedIn)?;

let token = cookies
.get("auth_token")
.ok_or(ChaosError::NotLoggedInError)?;
.ok_or(ChaosError::NotLoggedIn)?;

let claims = decode_auth_token(token, decoding_key, jwt_validator)
.ok_or(ChaosError::NotLoggedInError)?;
.ok_or(ChaosError::NotLoggedIn)?;

let pool = &app_state.db;
let user_id = claims.sub;
Expand Down
2 changes: 1 addition & 1 deletion backend/server/src/service/organisation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub async fn user_is_admin(
.await?.exists.expect("`exists` should always exist in this query result");

if !is_admin {
return Err(ChaosError::UnauthorizedError);
return Err(ChaosError::Unauthorized);
}

Ok(())
Expand Down

0 comments on commit 0b9f028

Please sign in to comment.