chore(users): add password to user data for addNewUser
This commit is contained in:
parent
6cd0152636
commit
2490f8e69f
@ -1,4 +1,4 @@
|
|||||||
-- SPDX-FileCopyrightText: 2022-2023 Gregor Kleen <gregor@kleen.consulting>, Sarah Vaupel <sarah.vaupel@ifi.lmu.de>, Steffen Jost <jost@tcs.ifi.lmu.de>, Winnie Ros <winnie.ros@campus.lmu.de>
|
-- SPDX-FileCopyrightText: 2022-2024 Sarah Vaupel <sarah.vaupel@uniworx.de>, Gregor Kleen <gregor@kleen.consulting>, Sarah Vaupel <sarah.vaupel@ifi.lmu.de>, Steffen Jost <jost@tcs.ifi.lmu.de>, Winnie Ros <winnie.ros@campus.lmu.de>
|
||||||
--
|
--
|
||||||
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
-- SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
@ -35,21 +35,18 @@ adminUserForm template = renderAForm FormStandard
|
|||||||
<*> aopt (textField & cfStrip) (fslI MsgAdminUserPinPassword) (audPinPassword <$> template)
|
<*> aopt (textField & cfStrip) (fslI MsgAdminUserPinPassword) (audPinPassword <$> template)
|
||||||
<*> areq (emailField & cfCI) (fslI MsgAdminUserEmail) (audEmail <$> template)
|
<*> areq (emailField & cfCI) (fslI MsgAdminUserEmail) (audEmail <$> template)
|
||||||
<*> areq (textField & cfStrip & cfCI) (fslI MsgAdminUserIdent) (audIdent <$> template)
|
<*> areq (textField & cfStrip & cfCI) (fslI MsgAdminUserIdent) (audIdent <$> template)
|
||||||
<*> areq (selectField optionsFinite) (fslI MsgAdminUserAuth & setTooltip MsgAdminUserAuthTooltip) (audAuth <$> template <|> Just AuthKindLDAP)
|
<*> aopt passwordField (fslI MsgAdminUserPassword) (audPassword <$> template)
|
||||||
<*> aopt uuidField (fslI MsgAdminUserAzureId) (audAzureId <$> template)
|
|
||||||
|
|
||||||
-- | Like `addNewUser`, but starts background jobs and tries to notify users, if applicable (i.e. /= AuthNoLogin )
|
-- | Like `addNewUser`, but starts background jobs and tries to notify users
|
||||||
addNewUserNotify :: AddUserData -> Handler (Maybe UserId)
|
addNewUserNotify :: AddUserData -> Handler (Maybe UserId)
|
||||||
addNewUserNotify aud = do
|
addNewUserNotify aud = do
|
||||||
mbUid <- addNewUser aud
|
mbUid <- addNewUser aud
|
||||||
case mbUid of
|
case mbUid of
|
||||||
Nothing -> return Nothing
|
Nothing -> return Nothing
|
||||||
Just uid -> runDBJobs $ do
|
Just uid -> runDBJobs $ do
|
||||||
queueDBJob $ JobSynchroniseUserdbUser uid
|
queueDBJob $ JobSynchroniseUser uid
|
||||||
let authKind = audAuth aud
|
when (is _Just $ audPassword aud) $ do
|
||||||
when (authKind /= AuthKindNoLogin) $
|
|
||||||
queueDBJob . JobQueueNotification $ NotificationUserAuthModeUpdate uid
|
queueDBJob . JobQueueNotification $ NotificationUserAuthModeUpdate uid
|
||||||
when (authKind == AuthKindPWHash) $
|
|
||||||
queueDBJob $ JobSendPasswordReset uid
|
queueDBJob $ JobSendPasswordReset uid
|
||||||
return $ Just uid
|
return $ Just uid
|
||||||
|
|
||||||
|
|||||||
@ -12,9 +12,6 @@ module Utils.Users
|
|||||||
import Import
|
import Import
|
||||||
|
|
||||||
|
|
||||||
-- TODO: addNewUser might be redundant; use upsertUser instead?
|
|
||||||
|
|
||||||
|
|
||||||
data AddUserData = AddUserData
|
data AddUserData = AddUserData
|
||||||
{ audTitle :: Maybe Text
|
{ audTitle :: Maybe Text
|
||||||
, audFirstName :: Text
|
, audFirstName :: Text
|
||||||
@ -33,6 +30,7 @@ data AddUserData = AddUserData
|
|||||||
, audPinPassword :: Maybe Text
|
, audPinPassword :: Maybe Text
|
||||||
, audEmail :: UserEmail
|
, audEmail :: UserEmail
|
||||||
, audIdent :: UserIdent
|
, audIdent :: UserIdent
|
||||||
|
, audPassword :: Maybe Text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -45,7 +43,7 @@ addNewUser AddUserData{..} = do
|
|||||||
newUser = User
|
newUser = User
|
||||||
{ userIdent = audIdent
|
{ userIdent = audIdent
|
||||||
, userLastAuthentication = Nothing
|
, userLastAuthentication = Nothing
|
||||||
, userPasswordHash = Nothing
|
, userPasswordHash = audPassword
|
||||||
, userMaxFavourites = userDefaultMaxFavourites
|
, userMaxFavourites = userDefaultMaxFavourites
|
||||||
, userMaxFavouriteTerms = userDefaultMaxFavouriteTerms
|
, userMaxFavouriteTerms = userDefaultMaxFavouriteTerms
|
||||||
, userTheme = userDefaultTheme
|
, userTheme = userDefaultTheme
|
||||||
|
|||||||
Reference in New Issue
Block a user