Skip to content

Commit

Permalink
fix: resolve token validator when user logout (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lzyct authored Aug 21, 2024
1 parent 4588f42 commit d942abe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/core/middlewares/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl FromRequest for AuthMiddleware {

let user_id = di.auth_repository.verify_token(&token_data).map_err(|_| {
APIError::UnauthorizedMessage {
message: "Token verification failed".to_string(),
message: "The provided token has been revoked.".to_string(),
}
})?;

Expand Down
6 changes: 3 additions & 3 deletions src/features/auth/data/repository/auth_repository_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ impl AuthRepositoryImpl for AuthRepository {
}

fn is_valid_login_session(&self, user: Uuid, login_session: Uuid) -> bool {
login_history::table
!login_history::table
.filter(login_history_user_id.eq(&user))
.filter(login_history_id.eq(&login_session))
.execute(&mut self.source.get().unwrap())
.is_ok()
.load::<LoginHistory>(&mut self.source.get().unwrap())
.map_err(|_| APIError::InternalError).unwrap().is_empty()
}

fn update_password(&self, user: Uuid, params: UpdatePasswordParams) -> AppResult<()> {
Expand Down

0 comments on commit d942abe

Please sign in to comment.