-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from shield-auth/feat/api-user
Feat/api user
- Loading branch information
Showing
41 changed files
with
1,089 additions
and
943 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
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 was deleted.
Oops, something went wrong.
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
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,29 @@ | ||
use crate::{models::refresh_token, utils::check_locked_at_constraint}; | ||
use async_trait::async_trait; | ||
use sea_orm::{entity::prelude::*, sqlx::types::chrono::Utc, ActiveValue}; | ||
|
||
#[async_trait] | ||
impl ActiveModelBehavior for refresh_token::ActiveModel { | ||
/// Will be triggered before insert / update | ||
async fn before_save<C>(mut self, db: &C, _insert: bool) -> Result<Self, DbErr> | ||
where | ||
C: ConnectionTrait, | ||
{ | ||
if let ActiveValue::Set(ref locked_at) = self.locked_at { | ||
check_locked_at_constraint(locked_at)? | ||
} | ||
|
||
if let ActiveValue::Set(ref expires) = self.expires { | ||
if expires < &Utc::now().fixed_offset() { | ||
return Err(DbErr::Custom("Expires must be greater than created_at".to_owned())); | ||
} | ||
} | ||
|
||
refresh_token::Entity::delete_many() | ||
.filter(refresh_token::Column::Expires.lt(Utc::now())) | ||
.exec(db) | ||
.await?; | ||
|
||
Ok(self) | ||
} | ||
} |
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
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
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
Oops, something went wrong.