-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat(users): implement force set and force change password #4564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
#[cfg(feature = "olap")] | ||
#[async_trait] | ||
impl<A> AuthenticateAndFetch<(), A> for SinglePurposeJWTAuth | ||
where | ||
A: AppStateInfo + Sync, | ||
{ | ||
async fn authenticate_and_fetch( | ||
&self, | ||
request_headers: &HeaderMap, | ||
state: &A, | ||
) -> RouterResult<((), AuthenticationType)> { | ||
let payload = parse_jwt_payload::<A, SinglePurposeToken>(request_headers, state).await?; | ||
if payload.check_in_blacklist(state).await? { | ||
return Err(errors::ApiErrorResponse::InvalidJwtToken.into()); | ||
} | ||
|
||
Ok(( | ||
(), | ||
AuthenticationType::SinglePurposeJWT { | ||
user_id: payload.user_id, | ||
purpose: payload.purpose, | ||
}, | ||
)) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed.
@@ -43,8 +43,7 @@ impl SPTFlow { | |||
Self::AcceptInvitationFromEmail | Self::ResetPassword => Ok(true), | |||
Self::VerifyEmail => Ok(user.0.is_verified), | |||
// Final Checks | |||
// TODO: this should be based on last_password_modified_at as a placeholder using false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the From
impl for SPTFlow -> Token Purpose
is_verified: is_verified.unwrap_or(user.is_verified), | ||
preferred_merchant_id: preferred_merchant_id | ||
.clone() | ||
.or(user.preferred_merchant_id.clone()), | ||
..user.to_owned() | ||
}, | ||
storage::UserUpdate::PasswordUpdate { password } => storage::User { | ||
password: password.clone().unwrap_or(user.password.clone()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add last_password_changed_at
here.
Type of Change
Description
Additional Changes
Motivation and Context
Closes #4411
How did you test it?
Use the curl:
Response will 200 Ok for all successful password change.
If current password and new password is same then response will be Invalid password error.
Checklist
cargo +nightly fmt --all
cargo clippy