mirror of
https://github.com/streetwriters/notesnook-sync-server.git
synced 2026-10-08 13:31:09 +02:00
identity: many fixes to auth grant validation
This commit is contained in:
1 parent
abe7e67933
commit
dac2d7a577
3 files changed
+15
-12
No files matched your search
@@ -89,6 +89,14 @@ namespace Streetwriters.Identity.Validation
|
||||
var user = await UserManager.FindByIdAsync(userId);
|
||||
if (user == null) return;
|
||||
|
||||
var isLockedOut = await UserManager.IsLockedOutAsync(user);
|
||||
if (isLockedOut)
|
||||
{
|
||||
var timeLeft = user.LockoutEnd - DateTimeOffset.Now;
|
||||
context.Result = new LockedOutValidationResult(timeLeft);
|
||||
return;
|
||||
}
|
||||
|
||||
context.Result.Error = "invalid_mfa";
|
||||
context.Result.ErrorDescription = "Please provide a valid multi-factor authentication code.";
|
||||
|
||||
@@ -102,14 +110,6 @@ namespace Streetwriters.Identity.Validation
|
||||
return;
|
||||
}
|
||||
|
||||
var isLockedOut = await UserManager.IsLockedOutAsync(user);
|
||||
if (isLockedOut)
|
||||
{
|
||||
var timeLeft = user.LockoutEnd - DateTimeOffset.Now;
|
||||
context.Result = new LockedOutValidationResult(timeLeft);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mfaMethod == MFAMethods.RecoveryCode)
|
||||
{
|
||||
context.Result.ErrorDescription = "Please provide a valid multi-factor authentication recovery code.";
|
||||
@@ -132,8 +132,9 @@ namespace Streetwriters.Identity.Validation
|
||||
}
|
||||
}
|
||||
|
||||
await UserManager.ResetAccessFailedCountAsync(user);
|
||||
context.Result.IsError = false;
|
||||
context.Result.Subject = await TokenGenerationService.TransformTokenRequestAsync(context.Request, user, GrantType, new string[] { Config.MFA_PASSWORD_GRANT_TYPE_SCOPE });
|
||||
context.Result.Subject = await TokenGenerationService.TransformTokenRequestAsync(context.Request, user, GrantType, [Config.MFA_PASSWORD_GRANT_TYPE_SCOPE]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user