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