refactor(auth): UserConversionException -> DecodeUserException
This commit is contained in:
parent
c9fa627651
commit
a2903da109
@ -103,14 +103,14 @@ PWHashLoginTitle: Spezieller Funktionsnutzer Login
|
|||||||
PWHashLoginNote: Verwenden Sie dieses Formular nur, wenn Sie explizit dazu aufgefordert wurden. Alle anderen sollten das andere Login Formular verwenden!
|
PWHashLoginNote: Verwenden Sie dieses Formular nur, wenn Sie explizit dazu aufgefordert wurden. Alle anderen sollten das andere Login Formular verwenden!
|
||||||
DummyLoginTitle: Development-Login
|
DummyLoginTitle: Development-Login
|
||||||
InternalLoginError: Interner Fehler beim Login
|
InternalLoginError: Interner Fehler beim Login
|
||||||
UserInvalidIdent: Konnte anhand des Fraport Büko-Logins keine eindeutige Identifikation ermitteln
|
DecodeUserInvalidIdent: Konnte anhand des Fraport Büko-Logins keine eindeutige Identifikation ermitteln
|
||||||
UserInvalidEmail: Konnte anhand des Fraport Büko-Logins keine E-Mail-Addresse ermitteln
|
DecodeUserInvalidEmail: Konnte anhand des Fraport Büko-Logins keine E-Mail-Addresse ermitteln
|
||||||
UserInvalidDisplayName: Konnte anhand des Fraport Büko-Logins keinen vollen Namen ermitteln
|
DecodeUserInvalidDisplayName: Konnte anhand des Fraport Büko-Logins keinen vollen Namen ermitteln
|
||||||
UserInvalidGivenName: Konnte anhand des Fraport Büko-Logins keinen Vornamen ermitteln
|
DecodeUserInvalidGivenName: Konnte anhand des Fraport Büko-Logins keinen Vornamen ermitteln
|
||||||
UserInvalidSurname: Konnte anhand des Fraport Büko-Logins keinen Nachname ermitteln
|
DecodeUserInvalidSurname: Konnte anhand des Fraport Büko-Logins keinen Nachname ermitteln
|
||||||
UserInvalidTitle: Konnte anhand des Fraport Büko-Logins keinen akademischen Titel ermitteln
|
DecodeUserInvalidTitle: Konnte anhand des Fraport Büko-Logins keinen akademischen Titel ermitteln
|
||||||
UserInvalidFeaturesOfStudy parseErr@Text: Konnte anhand des Fraport Büko-Logins keine Studiengänge ermitteln
|
DecodeUserInvalidFeaturesOfStudy parseErr@Text: Konnte anhand des Fraport Büko-Logins keine Studiengänge ermitteln
|
||||||
UserInvalidAssociatedSchools parseErr@Text: Konnte anhand des Fraport Büko-Logins keine Bereiche ermitteln
|
DecodeUserInvalidAssociatedSchools parseErr@Text: Konnte anhand des Fraport Büko-Logins keine Bereiche ermitteln
|
||||||
InvalidCredentialsADNoSuchObject: Benutzereintrag existiert nicht
|
InvalidCredentialsADNoSuchObject: Benutzereintrag existiert nicht
|
||||||
InvalidCredentialsADLogonFailure: Ungültiges Passwort
|
InvalidCredentialsADLogonFailure: Ungültiges Passwort
|
||||||
InvalidCredentialsADAccountRestriction: Beschränkungen des Fraport Accounts verhindern Login
|
InvalidCredentialsADAccountRestriction: Beschränkungen des Fraport Accounts verhindern Login
|
||||||
|
|||||||
@ -104,14 +104,14 @@ PWHashLoginTitle: Special function user login
|
|||||||
PWHashLoginNote: Only use this login form if you have received special instructions to do so. All others should use the other login field.
|
PWHashLoginNote: Only use this login form if you have received special instructions to do so. All others should use the other login field.
|
||||||
DummyLoginTitle: Development login
|
DummyLoginTitle: Development login
|
||||||
InternalLoginError: Internal error during login
|
InternalLoginError: Internal error during login
|
||||||
UserInvalidIdent: Could not determine unique identification during Fraport Büko login
|
DecodeUserInvalidIdent: Could not determine unique identification during Fraport Büko login
|
||||||
UserInvalidEmail: Could not determine email address during Fraport Büko login
|
DecodeUserInvalidEmail: Could not determine email address during Fraport Büko login
|
||||||
UserInvalidDisplayName: Could not determine display name during Fraport Büko login
|
DecodeUserInvalidDisplayName: Could not determine display name during Fraport Büko login
|
||||||
UserInvalidGivenName: Could not determine given name during Fraport Büko login
|
DecodeUserInvalidGivenName: Could not determine given name during Fraport Büko login
|
||||||
UserInvalidSurname: Could not determine surname during Fraport Büko login
|
DecodeUserInvalidSurname: Could not determine surname during Fraport Büko login
|
||||||
UserInvalidTitle: Could not determine title during Fraport Büko login
|
DecodeUserInvalidTitle: Could not determine title during Fraport Büko login
|
||||||
UserInvalidFeaturesOfStudy parseErr: Could not determine features of study during Fraport Büko login
|
DecodeUserInvalidFeaturesOfStudy parseErr: Could not determine features of study during Fraport Büko login
|
||||||
UserInvalidAssociatedSchools parseErr: Could not determine associated departments during Fraport Büko login
|
DecodeUserInvalidAssociatedSchools parseErr: Could not determine associated departments during Fraport Büko login
|
||||||
InvalidCredentialsADNoSuchObject: User entry does not exist
|
InvalidCredentialsADNoSuchObject: User entry does not exist
|
||||||
InvalidCredentialsADLogonFailure: Invalid password
|
InvalidCredentialsADLogonFailure: Invalid password
|
||||||
InvalidCredentialsADAccountRestriction: Restrictions on your Fraport account prevent a login
|
InvalidCredentialsADAccountRestriction: Restrictions on your Fraport account prevent a login
|
||||||
|
|||||||
@ -7,7 +7,7 @@ module Foundation.Yesod.Auth
|
|||||||
, userLookupAndUpsert
|
, userLookupAndUpsert
|
||||||
, upsertUser
|
, upsertUser
|
||||||
, decodeUserTest
|
, decodeUserTest
|
||||||
, UserConversionException(..)
|
, DecodeUserException(..)
|
||||||
, updateUserLanguage
|
, updateUserLanguage
|
||||||
) where
|
) where
|
||||||
|
|
||||||
@ -89,10 +89,10 @@ authenticate creds@Creds{..} = liftHandler . runDB . withReaderT projectBackend
|
|||||||
$logErrorS "FetchUserException" $ tshow err
|
$logErrorS "FetchUserException" $ tshow err
|
||||||
mr <- getMessageRender
|
mr <- getMessageRender
|
||||||
excRecovery . ServerError $ mr MsgInternalLoginError
|
excRecovery . ServerError $ mr MsgInternalLoginError
|
||||||
, C.Handler $ \(cExc :: UserConversionException) -> do
|
, C.Handler $ \(dExc :: DecodeUserException) -> do
|
||||||
$logErrorS "Auth" $ tshow cExc
|
$logErrorS "Auth" $ tshow dExc
|
||||||
mr <- getMessageRender
|
mr <- getMessageRender
|
||||||
excRecovery . ServerError $ mr cExc
|
excRecovery . ServerError $ mr dExc
|
||||||
]
|
]
|
||||||
|
|
||||||
acceptExisting :: SqlPersistT (HandlerFor UniWorX) (AuthenticationResult UniWorX)
|
acceptExisting :: SqlPersistT (HandlerFor UniWorX) (AuthenticationResult UniWorX)
|
||||||
@ -132,16 +132,15 @@ authenticate creds@Creds{..} = liftHandler . runDB . withReaderT projectBackend
|
|||||||
-> acceptExisting
|
-> acceptExisting
|
||||||
|
|
||||||
|
|
||||||
-- TODO: rename to DecodeUserException (associate with function!)
|
data DecodeUserException
|
||||||
data UserConversionException
|
= DecodeUserInvalidIdent
|
||||||
= UserInvalidIdent
|
| DecodeUserInvalidEmail
|
||||||
| UserInvalidEmail
|
| DecodeUserInvalidDisplayName
|
||||||
| UserInvalidDisplayName
|
| DecodeUserInvalidGivenName
|
||||||
| UserInvalidGivenName
|
| DecodeUserInvalidSurname
|
||||||
| UserInvalidSurname
|
| DecodeUserInvalidTitle
|
||||||
| UserInvalidTitle
|
| DecodeUserInvalidFeaturesOfStudy Text
|
||||||
| UserInvalidFeaturesOfStudy Text
|
| DecodeUserInvalidAssociatedSchools Text
|
||||||
| UserInvalidAssociatedSchools Text
|
|
||||||
deriving (Eq, Ord, Read, Show, Generic)
|
deriving (Eq, Ord, Read, Show, Generic)
|
||||||
deriving anyclass (Exception)
|
deriving anyclass (Exception)
|
||||||
|
|
||||||
@ -304,7 +303,7 @@ decodeUser now UserDefaultConf{..} upsertData = do
|
|||||||
, Just ldapPrimaryKey'' <- assertM' (not . Text.null) $ Text.strip ldapPrimaryKey'
|
, Just ldapPrimaryKey'' <- assertM' (not . Text.null) $ Text.strip ldapPrimaryKey'
|
||||||
-> return $ CI.mk ldapPrimaryKey''
|
-> return $ CI.mk ldapPrimaryKey''
|
||||||
| otherwise
|
| otherwise
|
||||||
-> throwM UserInvalidIdent
|
-> throwM DecodeUserInvalidIdent
|
||||||
|
|
||||||
let
|
let
|
||||||
(azureSurname, azureFirstName, azureDisplayName, azureEmail, azureTelephone, azureMobile, azureLanguages)
|
(azureSurname, azureFirstName, azureDisplayName, azureEmail, azureTelephone, azureMobile, azureLanguages)
|
||||||
@ -437,7 +436,7 @@ decodeUserTest :: ( MonadHandler m
|
|||||||
, MonadCatch m
|
, MonadCatch m
|
||||||
)
|
)
|
||||||
=> NonEmpty UpsertUserData
|
=> NonEmpty UpsertUserData
|
||||||
-> m (Either UserConversionException (User, [Update User]))
|
-> m (Either DecodeUserException (User, [Update User]))
|
||||||
decodeUserTest decodeData = do
|
decodeUserTest decodeData = do
|
||||||
now <- liftIO getCurrentTime
|
now <- liftIO getCurrentTime
|
||||||
userDefaultConf <- getsYesod $ view _appUserDefaults
|
userDefaultConf <- getsYesod $ view _appUserDefaults
|
||||||
@ -495,4 +494,4 @@ updateUserLanguage Nothing = runMaybeT $ do
|
|||||||
setRegisteredCookie CookieLang lang
|
setRegisteredCookie CookieLang lang
|
||||||
return lang
|
return lang
|
||||||
|
|
||||||
embedRenderMessage ''UniWorX ''UserConversionException id
|
embedRenderMessage ''UniWorX ''DecodeUserException id
|
||||||
|
|||||||
Reference in New Issue
Block a user