From 4d7e9d3f8a625e0363cc7e114a170ef9e3cf6bba Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Mon, 25 Mar 2019 12:08:47 +0900 Subject: [PATCH] Rewrite the BitpayAuthHandler more clearly --- BTCPayServer/Security/BitpayAuthentication.cs | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/BTCPayServer/Security/BitpayAuthentication.cs b/BTCPayServer/Security/BitpayAuthentication.cs index 9ea5c6297..f68403fe4 100644 --- a/BTCPayServer/Security/BitpayAuthentication.cs +++ b/BTCPayServer/Security/BitpayAuthentication.cs @@ -71,24 +71,22 @@ namespace BTCPayServer.Security success = storeId != null; } - if (success.HasValue) + if (success is true) { - if (success.Value) + if (storeId != null) { - if (storeId != null) - { - claims.Add(new Claim(Policies.CanCreateInvoice.Key, storeId)); - var store = await _StoreRepository.FindStore(storeId); - store.AdditionalClaims.AddRange(claims); - Context.Request.HttpContext.SetStoreData(store); - } - return AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(new ClaimsIdentity(claims, Policies.BitpayAuthentication)), Policies.BitpayAuthentication)); - } - else - { - return AuthenticateResult.Fail("Invalid credentials"); + claims.Add(new Claim(Policies.CanCreateInvoice.Key, storeId)); + var store = await _StoreRepository.FindStore(storeId); + store.AdditionalClaims.AddRange(claims); + Context.Request.HttpContext.SetStoreData(store); } + return AuthenticateResult.Success(new AuthenticationTicket(new ClaimsPrincipal(new ClaimsIdentity(claims, Policies.BitpayAuthentication)), Policies.BitpayAuthentication)); } + else if (success is false) + { + return AuthenticateResult.Fail("Invalid credentials"); + } + // else if (success is null) } return AuthenticateResult.NoResult(); }