chore(users): tweak addNewUser to conform to new model
This commit is contained in:
parent
ed54b666ec
commit
3d1908d71a
@ -460,8 +460,7 @@ upsertAvsUserById api = do
|
||||
, audPinPassword = userPin
|
||||
, audEmail = fakeNo -- Email is unknown in this version of the avs query, to be updated later (FUTURE TODO)
|
||||
, audIdent = fakeIdent -- use AvsPersonId instead
|
||||
, audAuth = maybe AuthKindNoLogin (const AuthKindAzure) avsPersonInternalPersonalNo -- FUTURE TODO: if email is known, use AuthKinfPWHash for email invite, if no internal personnel number is known
|
||||
, audAzureId = Nothing -- TODO
|
||||
--, audAuth = maybe AuthKindNoLogin (const AuthKindAzure) avsPersonInternalPersonalNo -- FUTURE TODO: if email is known, use AuthKinfPWHash for email invite, if no internal personnel number is known
|
||||
}
|
||||
mbUid <- addNewUser newUsr -- triggers JobSynchroniseUserdbUser, JobSendPasswordReset and NotificationUserAutoModeUpdate -- TODO: check if these are failsafe
|
||||
whenIsJust mbUid $ \uid -> runDB $ do
|
||||
|
||||
@ -5,31 +5,15 @@
|
||||
{-# OPTIONS_GHC -fno-warn-unused-top-binds #-}
|
||||
|
||||
module Utils.Users
|
||||
( AuthenticationKind(..)
|
||||
, AddUserData(..)
|
||||
( AddUserData(..)
|
||||
, addNewUser
|
||||
) where
|
||||
|
||||
import Import
|
||||
|
||||
|
||||
data AuthenticationKind = AuthKindLDAP | AuthKindAzure | AuthKindPWHash | AuthKindNoLogin
|
||||
deriving (Eq, Ord, Read, Show, Enum, Bounded, Generic, Universe, Finite)
|
||||
embedRenderMessage ''UniWorX ''AuthenticationKind id
|
||||
nullaryPathPiece ''AuthenticationKind $ camelToPathPiece' 2
|
||||
-- TODO: addNewUser might be redundant; use upsertUser instead?
|
||||
|
||||
mkAuthMode :: AuthenticationKind -> AuthenticationMode
|
||||
mkAuthMode AuthKindLDAP = AuthLDAP
|
||||
mkAuthMode AuthKindAzure = AuthAzure
|
||||
mkAuthMode AuthKindPWHash = AuthPWHash ""
|
||||
mkAuthMode AuthKindNoLogin = AuthNoLogin
|
||||
|
||||
{-
|
||||
classifyAuth :: AuthenticationMode -> AuthenticationKind
|
||||
classifyAuth AuthLDAP = AuthKindLDAP
|
||||
classifyAuth AuthPWHash{} = AuthKindPWHash
|
||||
classifyAuth AuthNoLogin = AuthKindNoLogin
|
||||
-}
|
||||
|
||||
data AddUserData = AddUserData
|
||||
{ audTitle :: Maybe Text
|
||||
@ -49,8 +33,6 @@ data AddUserData = AddUserData
|
||||
, audPinPassword :: Maybe Text
|
||||
, audEmail :: UserEmail
|
||||
, audIdent :: UserIdent
|
||||
, audAuth :: AuthenticationKind
|
||||
, audAzureId :: Maybe UUID
|
||||
}
|
||||
|
||||
|
||||
@ -62,6 +44,8 @@ addNewUser AddUserData{..} = do
|
||||
let
|
||||
newUser = User
|
||||
{ userIdent = audIdent
|
||||
, userLastLogin = Nothing
|
||||
, userPasswordHash = Nothing
|
||||
, userMaxFavourites = userDefaultMaxFavourites
|
||||
, userMaxFavouriteTerms = userDefaultMaxFavouriteTerms
|
||||
, userTheme = userDefaultTheme
|
||||
@ -78,11 +62,6 @@ addNewUser AddUserData{..} = do
|
||||
, userCsvOptions = def { csvFormat = review csvPreset CsvPresetXlsx }
|
||||
, userTokensIssuedAfter = Nothing
|
||||
, userCreated = now
|
||||
, userLastLdapSynchronisation = Nothing
|
||||
, userLdapPrimaryKey = audFPersonalNumber
|
||||
, userLastAzureSynchronisation = Nothing
|
||||
, userAzurePrimaryKey = audAzureId
|
||||
, userLastAuthentication = Nothing
|
||||
, userEmail = audEmail
|
||||
, userDisplayName = audDisplayName
|
||||
, userDisplayEmail = audDisplayEmail
|
||||
@ -100,6 +79,5 @@ addNewUser AddUserData{..} = do
|
||||
, userPrefersPostal = audPrefersPostal
|
||||
, userPinPassword = audPinPassword
|
||||
, userMatrikelnummer = audMatriculation
|
||||
, userAuthentication = mkAuthMode audAuth
|
||||
}
|
||||
runDB $ insertUnique newUser
|
||||
Reference in New Issue
Block a user