From dad3039c064d6bd636841604a0061709c5ca3720 Mon Sep 17 00:00:00 2001 From: Kukks Date: Tue, 14 Jan 2020 09:48:06 +0100 Subject: [PATCH] throw on non-u2f specific errors --- BTCPayServer/Controllers/AccountController.cs | 4 ++-- BTCPayServer/Controllers/ManageController.U2F.cs | 3 ++- BTCPayServer/U2F/U2FService.cs | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/BTCPayServer/Controllers/AccountController.cs b/BTCPayServer/Controllers/AccountController.cs index 7286dc07e..d6797bb03 100644 --- a/BTCPayServer/Controllers/AccountController.cs +++ b/BTCPayServer/Controllers/AccountController.cs @@ -23,6 +23,7 @@ using BTCPayServer.U2F.Models; using Newtonsoft.Json; using NicolasDorier.RateLimits; using BTCPayServer.Data; +using U2F.Core.Exceptions; namespace BTCPayServer.Controllers { @@ -235,9 +236,8 @@ namespace BTCPayServer.Controllers errorMessage = "Invalid login attempt."; } - catch (Exception e) + catch (U2fException e) { - errorMessage = e.Message; } diff --git a/BTCPayServer/Controllers/ManageController.U2F.cs b/BTCPayServer/Controllers/ManageController.U2F.cs index a07c65739..c827194f9 100644 --- a/BTCPayServer/Controllers/ManageController.U2F.cs +++ b/BTCPayServer/Controllers/ManageController.U2F.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using BTCPayServer.Models; using BTCPayServer.U2F.Models; using Microsoft.AspNetCore.Mvc; +using U2F.Core.Exceptions; namespace BTCPayServer.Controllers { @@ -65,7 +66,7 @@ namespace BTCPayServer.Controllers return RedirectToAction("U2FAuthentication"); } } - catch (Exception e) + catch (U2fException e) { errorMessage = e.Message; } diff --git a/BTCPayServer/U2F/U2FService.cs b/BTCPayServer/U2F/U2FService.cs index da8c42bf8..52f1e6edc 100644 --- a/BTCPayServer/U2F/U2FService.cs +++ b/BTCPayServer/U2F/U2FService.cs @@ -12,6 +12,7 @@ using U2F.Core.Models; using U2F.Core.Utils; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Query; +using U2F.Core.Exceptions; namespace BTCPayServer.U2F { @@ -115,7 +116,7 @@ namespace BTCPayServer.U2F if (duplicate) { - throw new InvalidOperationException("The U2F Device has already been registered with this user"); + throw new U2fException("The U2F Device has already been registered with this user"); } await context.U2FDevices.AddAsync(new U2FDevice()