1
0
mirror of https://github.com/bitwarden/server synced 2025-12-17 08:43:27 +00:00

identitysever cleanup

This commit is contained in:
Kyle Spearrin
2017-01-20 22:26:19 -05:00
parent 3348b07ce2
commit 52b8fef26f
3 changed files with 15 additions and 6 deletions

View File

@@ -1,4 +1,5 @@
using Bit.Core.Domains;
using Bit.Api.Models.Response;
using Bit.Core.Domains;
using Bit.Core.Enums;
using Bit.Core.Exceptions;
using Bit.Core.Repositories;
@@ -44,7 +45,6 @@ namespace Bit.Api.IdentityServer
if(!twoFactorRequest && await TwoFactorRequiredAsync(user))
{
context.Result = new GrantValidationResult(TokenRequestErrors.InvalidGrant, "Two factor code required.",
// TODO: return something better?
new System.Collections.Generic.Dictionary<string, object> { { "TwoFactorRequired", true } });
return;
}
@@ -66,9 +66,12 @@ namespace Bit.Api.IdentityServer
}
}
context.Result = new GrantValidationResult(TokenRequestErrors.InvalidGrant,
twoFactorRequest ? "Code is not correct. Try again." : "Username or password is incorrect. Try again.",
new System.Collections.Generic.Dictionary<string, object> { { "Error", true } });
await Task.Delay(2000);
context.Result = new GrantValidationResult(TokenRequestErrors.InvalidGrant, customResponse:
new System.Collections.Generic.Dictionary<string, object> { {
"ErrorModel", new ErrorResponseModel(twoFactorRequest ?
"Code is not correct. Try again." : "Username or password is incorrect. Try again.")
} });
}
private async Task<bool> TwoFactorRequiredAsync(User user)