code deduplication

This commit is contained in:
nek0 2019-10-14 17:39:38 +02:00
parent 3a5cb7c5ac
commit 892d3f0610

View file

@ -87,14 +87,10 @@ authManageDeleteAuth (Just (uid, method)) adid = do
case authOverviewMethod currentad of case authOverviewMethod currentad of
PrimaryPass -> if validateDeletion ads PrimaryPass -> if validateDeletion ads
then void (deleteAuthDataById adid conn) then void (deleteAuthDataById adid conn)
else throwError $ err406 else throwUnacceptableDeletionError
{ errBody = "You need at least one primary password or challenge response authentication"
}
ChallengeResponse -> if validateDeletion ads ChallengeResponse -> if validateDeletion ads
then void (deleteAuthDataById adid conn) then void (deleteAuthDataById adid conn)
else throwError $ err406 else throwUnacceptableDeletionError
{ errBody = "You need at least one primary password or challenge response authentication"
}
_ -> void $ deleteAuthDataById adid conn _ -> void $ deleteAuthDataById adid conn
else else
throwError $ err401 throwError $ err401
@ -107,6 +103,10 @@ authManageDeleteAuth (Just (uid, method)) adid = do
authOverviewMethod ad == ChallengeResponse) authOverviewMethod ad == ChallengeResponse)
ads ads
) )
throwUnacceptableDeletionError =
throwError $ err406
{ errBody = "You need at least one primary password or challenge response authentication"
}
authManageDeleteAuth Nothing _ = do authManageDeleteAuth Nothing _ = do
throwError $ err401 throwError $ err401
{ errBody = "Unauthorized access" { errBody = "Unauthorized access"