From 892d3f061058d4f4dffc971559ff60beb08bdac8 Mon Sep 17 00:00:00 2001 From: nek0 Date: Mon, 14 Oct 2019 17:39:38 +0200 Subject: [PATCH] code deduplication --- src/Control/Auth.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Control/Auth.hs b/src/Control/Auth.hs index 71a20f7..7302eb7 100644 --- a/src/Control/Auth.hs +++ b/src/Control/Auth.hs @@ -87,14 +87,10 @@ authManageDeleteAuth (Just (uid, method)) adid = do case authOverviewMethod currentad of PrimaryPass -> if validateDeletion ads then void (deleteAuthDataById adid conn) - else throwError $ err406 - { errBody = "You need at least one primary password or challenge response authentication" - } + else throwUnacceptableDeletionError ChallengeResponse -> if validateDeletion ads then void (deleteAuthDataById adid conn) - else throwError $ err406 - { errBody = "You need at least one primary password or challenge response authentication" - } + else throwUnacceptableDeletionError _ -> void $ deleteAuthDataById adid conn else throwError $ err401 @@ -107,6 +103,10 @@ authManageDeleteAuth (Just (uid, method)) adid = do authOverviewMethod ad == ChallengeResponse) ads ) + throwUnacceptableDeletionError = + throwError $ err406 + { errBody = "You need at least one primary password or challenge response authentication" + } authManageDeleteAuth Nothing _ = do throwError $ err401 { errBody = "Unauthorized access"