Skip to content

Commit

Permalink
Refactor credential counter update
Browse files Browse the repository at this point in the history
Simplify the update of credential counters by replacing a map statement with an if let statement. Additionally, add a FIXME comment to integrate blockchain recording and replay attack checks in the future.
  • Loading branch information
arkavo-com committed Sep 4, 2024
1 parent 70e08f4 commit 555aea2
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/authn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,16 +332,13 @@ pub async fn finish_authentication(
{
Ok(auth_result) => {
let mut users_guard = app_state.accounts.lock().await;
// Update the credential counter, if possible.
users_guard
.keys
.get_mut(&user_unique_id)
.map(|keys| {
keys.iter_mut().for_each(|sk| {
sk.update_credential(&auth_result);
})
})
.ok_or(UserHasNoCredentials)?;
// Update the credential counter, if possible.
// FIXME record on blockchain, then check above for replay attach
if let Some(keys) = users_guard.keys.get_mut(&user_unique_id) {
keys.iter_mut().for_each(|sk| {
sk.update_credential(&auth_result);
});
}
// Generate JWT token
let token = generate_jwt(user_unique_id, &app_state)?;
// Return JSON response with JWT token
Expand Down

0 comments on commit 555aea2

Please sign in to comment.