-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add emergency logout job for users
- Loading branch information
Showing
3 changed files
with
29 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use crate::database::repository::{auth_tokens, developers, refresh_tokens}; | ||
use crate::types::api::ApiError; | ||
use sqlx::PgConnection; | ||
|
||
pub async fn logout_user(username: &str, conn: &mut PgConnection) -> Result<(), ApiError> { | ||
let dev = developers::get_one_by_username(username, conn) | ||
.await? | ||
.ok_or(ApiError::NotFound("Developer not found".into()))?; | ||
|
||
auth_tokens::remove_developer_tokens(dev.id, conn).await?; | ||
refresh_tokens::remove_developer_tokens(dev.id, conn).await?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod cleanup_downloads; | ||
pub mod logout_user; | ||
pub mod migrate; | ||
pub mod token_cleanup; |