Setup: do not change email address there, go to the dedicated page instead.
parent
51d8f07b9e
commit
3af5c03199
|
@ -547,14 +547,7 @@ handleAction = case _ of
|
|||
-- Once the user has been deleted, just act like it was just a disconnection.
|
||||
handleAction $ Disconnection
|
||||
|
||||
SetupInterface.ChangeEmailAddress email_address -> do
|
||||
message <- H.liftEffect $ AuthD.serialize $ AuthD.MkModUser { user: Nothing
|
||||
, admin: Nothing
|
||||
, password: Nothing
|
||||
, email: Just email_address
|
||||
}
|
||||
H.tell _ws_auth unit (WS.ToSend message)
|
||||
|
||||
SetupInterface.ChangeEmailAddress -> handleAction $ Routing Migration
|
||||
SetupInterface.ChangePassword pass -> do
|
||||
message <- H.liftEffect $ AuthD.serialize $ AuthD.MkModUser { user: Nothing
|
||||
, admin: Nothing
|
||||
|
@ -691,8 +684,11 @@ handleAction = case _ of
|
|||
_ -> pure unit
|
||||
(AuthD.GotNewEmailTokenSent _) -> do
|
||||
handleAction $ Log $ SuccessLog "New email address is pending. Please enter validation token."
|
||||
(AuthD.GotNewEmailAddressValidated _) -> do
|
||||
(AuthD.GotNewEmailAddressValidated msg) -> do
|
||||
handleAction $ Log $ SuccessLog "New email address has been validated."
|
||||
handleAction $ AddNotif $ GoodNotification "Your new email address is now valid."
|
||||
H.modify_ _ { user_data = Just (Tuple (Just msg.email) Nothing) }
|
||||
handleAction $ Routing DomainList
|
||||
(AuthD.GotErrorMustBeAuthenticated _) -> do
|
||||
handleAction $ Log $ ErrorLog "received a GotErrorMustBeAuthenticated message."
|
||||
handleAction $ AddNotif $ BadNotification "Sorry, you must be authenticated to perform this action."
|
||||
|
|
|
@ -292,9 +292,9 @@ codecGotNewEmailTokenSent ∷ CA.JsonCodec NewEmailTokenSent
|
|||
codecGotNewEmailTokenSent = CA.object "NewEmailTokenSent" (CAR.record {})
|
||||
|
||||
{- 15 -}
|
||||
type NewEmailAddressValidated = {}
|
||||
type NewEmailAddressValidated = { email :: Email.Email }
|
||||
codecGotNewEmailAddressValidated ∷ CA.JsonCodec NewEmailAddressValidated
|
||||
codecGotNewEmailAddressValidated = CA.object "NewEmailAddressValidated" (CAR.record {})
|
||||
codecGotNewEmailAddressValidated = CA.object "NewEmailAddressValidated" (CAR.record {email: Email.codec})
|
||||
|
||||
{- 20 -}
|
||||
type ErrorMustBeAuthenticated = {}
|
||||
|
|
|
@ -19,17 +19,15 @@ import Bulma as Bulma
|
|||
import CSSClasses as C
|
||||
|
||||
import App.Type.Email as Email
|
||||
import App.Validation.Email as E
|
||||
import App.Validation.Password as P
|
||||
|
||||
import App.Type.LogMessage
|
||||
import App.Message.AuthenticationDaemon as AuthD
|
||||
import App.DisplayErrors (show_error_email)
|
||||
|
||||
data Output
|
||||
= Log LogMessage
|
||||
| ChangePassword String
|
||||
| ChangeEmailAddress Email.Email
|
||||
| ChangeEmailAddress
|
||||
| DeleteUserAccount
|
||||
|
||||
-- | The component's parent provides received messages.
|
||||
|
@ -53,9 +51,7 @@ data Action
|
|||
| ChangePasswordAttempt Event -- validation
|
||||
| SendChangePasswordMessage -- sends the message
|
||||
|
||||
| HandleNewEmail String -- user input
|
||||
| ChangeEmailAttempt Event -- validation
|
||||
| SendChangeEmailAddressMessage -- sends the message
|
||||
| RouteChangeEmailAddressPage
|
||||
|
||||
| CancelModal
|
||||
| DeleteAccountPopup
|
||||
|
@ -69,7 +65,6 @@ data Modal
|
|||
|
||||
type State =
|
||||
{ newPasswordForm :: StateNewPasswordForm
|
||||
, new_email_address :: String
|
||||
, emails :: Tuple (Maybe Email.Email) (Maybe Email.Email)
|
||||
, modal :: Modal
|
||||
}
|
||||
|
@ -88,22 +83,22 @@ component =
|
|||
initialState :: Input -> State
|
||||
initialState emails =
|
||||
{ newPasswordForm: { password: "", confirmation: "" }
|
||||
, new_email_address: ""
|
||||
, emails
|
||||
, modal: NoModal
|
||||
}
|
||||
|
||||
render :: forall m. State -> H.ComponentHTML Action () m
|
||||
render { modal, newPasswordForm, new_email_address, emails } =
|
||||
render { modal, newPasswordForm, emails } =
|
||||
Bulma.section_small
|
||||
[ render_emails emails
|
||||
, Bulma.hr
|
||||
, case modal of
|
||||
DeleteAccountModal -> render_delete_account_modal
|
||||
NoModal -> Bulma.columns_ [ b [ Bulma.h3 "Change email address", render_new_email_form ]
|
||||
, b [ Bulma.h3 "Change password", render_new_password_form ]
|
||||
, b [ Bulma.h3 "Delete account", render_delete_account ]
|
||||
]
|
||||
NoModal -> Bulma.columns_
|
||||
[ b [ Bulma.btn_ [C.is_large, C.is_info] "Change email address" RouteChangeEmailAddressPage ]
|
||||
, b [ Bulma.h3 "Change password", render_new_password_form ]
|
||||
, b [ Bulma.h3 "Delete account", render_delete_account ]
|
||||
]
|
||||
]
|
||||
|
||||
where
|
||||
|
@ -121,12 +116,6 @@ render { modal, newPasswordForm, new_email_address, emails } =
|
|||
|
||||
render_delete_account = Bulma.alert_btn "Delete my account" DeleteAccountPopup
|
||||
|
||||
render_new_email_form = HH.form
|
||||
[ HE.onSubmit ChangeEmailAttempt ]
|
||||
[ Bulma.box_input "emailAddress" "New email address" "foo@bar.com" HandleNewEmail new_email_address
|
||||
, Bulma.btn_validation
|
||||
]
|
||||
|
||||
render_new_password_form = HH.form
|
||||
[ HE.onSubmit ChangePasswordAttempt ]
|
||||
[ Bulma.box_password "passwordNEWPASS" "New Password" "password"
|
||||
|
@ -153,9 +142,6 @@ handleAction = case _ of
|
|||
NEWPASS_INP_password v -> H.modify_ _ { newPasswordForm { password = v } }
|
||||
NEWPASS_INP_confirmation v -> H.modify_ _ { newPasswordForm { confirmation = v } }
|
||||
|
||||
HandleNewEmail email_address -> do
|
||||
H.modify_ _ { new_email_address = email_address }
|
||||
|
||||
CancelModal -> do
|
||||
H.modify_ _ { modal = NoModal }
|
||||
DeleteAccountPopup -> do
|
||||
|
@ -164,17 +150,6 @@ handleAction = case _ of
|
|||
H.raise $ DeleteUserAccount
|
||||
handleAction $ CancelModal
|
||||
|
||||
ChangeEmailAttempt ev -> do
|
||||
H.liftEffect $ Event.preventDefault ev
|
||||
|
||||
{ new_email_address } <- H.get
|
||||
case new_email_address of
|
||||
"" -> H.raise $ Log $ UnableToSend "Please, write your new email address."
|
||||
email_address -> do
|
||||
case E.email email_address of
|
||||
Left errors -> H.raise $ Log $ UnableToSend $ A.fold $ map show_error_email errors
|
||||
Right _ -> handleAction SendChangeEmailAddressMessage
|
||||
|
||||
ChangePasswordAttempt ev -> do
|
||||
H.liftEffect $ Event.preventDefault ev
|
||||
|
||||
|
@ -189,10 +164,7 @@ handleAction = case _ of
|
|||
Right _ -> handleAction SendChangePasswordMessage
|
||||
else H.raise $ Log $ UnableToSend "Confirmation differs from password"
|
||||
|
||||
SendChangeEmailAddressMessage -> do
|
||||
state <- H.get
|
||||
H.raise $ Log $ SystemLog "Changing the email address"
|
||||
H.raise $ ChangeEmailAddress (Email.Email state.new_email_address)
|
||||
RouteChangeEmailAddressPage -> H.raise $ ChangeEmailAddress
|
||||
|
||||
SendChangePasswordMessage -> do
|
||||
state <- H.get
|
||||
|
|
Loading…
Reference in New Issue