1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-22 12:15:36 +01: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)

View File

@ -10,6 +10,12 @@ namespace Bit.Api.Models.Response
: base("error")
{ }
public ErrorResponseModel(string message)
: this()
{
Message = message;
}
public ErrorResponseModel(ModelStateDictionary modelState)
: this()
{

View File

@ -14,7 +14,7 @@ namespace Bit.Api.Utilities
{
public override void OnException(ExceptionContext context)
{
var errorModel = new ErrorResponseModel { Message = "An error has occured." };
var errorModel = new ErrorResponseModel("An error has occured.");
var exception = context.Exception;
if(exception == null)