@@ -53,7 +53,7 @@ import GHCJS.Nullable (Nullable(..), nullableToMaybe, maybeToNullable)
5353import GHCJS.Types (JSVal , jsval )
5454import Happstack.Authenticate.Core (ClientInitData (.. ), Email (.. ), User (.. ), Username (.. ), AuthenticateURL (AmAuthenticated , AuthenticationMethods , InitClient , Logout ), AuthenticationMethod (.. ), JSONResponse (.. ), Status (.. ), jsonOptions )
5555import qualified Happstack.Authenticate.Core as Authenticate
56- import Happstack.Authenticate.Password.Core (ChangePasswordData (.. ), UserPass (.. ), NewAccountData (.. ), ResetPasswordData (.. ), RequestResetPasswordData (.. ))
56+ import Happstack.Authenticate.Password.Core (ChangePasswordData (.. ), UserPass (.. ), NewAccountData (.. ), ResetPasswordData (.. ), RequestResetPasswordData (.. ), PartialMsgs ( .. ) )
5757import Happstack.Authenticate.Password.URL (AccountURL (Password ), PasswordURL (Account , Token , PasswordRequestReset , PasswordReset ),passwordAuthenticationMethod )
5858import GHC.Generics (Generic )
5959import GHCJS.DOM.Document (setCookie )
@@ -84,23 +84,8 @@ getElementByNameAttr :: JSElement -> JSString -> IO (Maybe JSElement)
8484getElementByNameAttr node name =
8585 querySelector node (" [name='" <> name <> " ']" )
8686
87- data HappstackAuthenticateI18N = HappstackAuthenticateI18N
8887
89- data PartialMsgs
90- = UsernameMsg
91- | EmailMsg
92- | PasswordMsg
93- | PasswordConfirmationMsg
94- | SignUpMsg
95- | SignInMsg
96- | LogoutMsg
97- | OldPasswordMsg
98- | NewPasswordMsg
99- | NewPasswordConfirmationMsg
100- | ChangePasswordMsg
101- | ChangePasswordAuthRequiredMsg
102- | RequestPasswordResetMsg
103- | PasswordChangedMsg
88+ data HappstackAuthenticateI18N = HappstackAuthenticateI18N
10489
10590mkMessageFor " HappstackAuthenticateI18N" " PartialMsgs" " messages/password/partials" " en"
10691
@@ -304,9 +289,7 @@ requestResetPasswordForm =
304289 -- let changePasswordFn = "resetPassword('" <> url <> "')"
305290 [domc |
306291 <d-if cond="(_passwordResetRequested model)">
307-
308292 <p>{{ _requestResetPasswordMsg model }}</p>
309-
310293 <form role="form">
311294 <div class="form-group happstack-authenticate-error">{{_requestResetPasswordMsg model}}</div>
312295 <div class="form-group">
@@ -326,17 +309,22 @@ resetPasswordForm =
326309 <div>
327310 <form role="form">
328311 <div class="form-group">{{_resetPasswordMsg model}}</div>
329- <div class="form-group">
330- <label class="sr-only" for="reset-password">{{ render PasswordMsg }}</label>
331- <input class="form-control" type="password" id="rp-reset-password" name="reset-password" placeholder="{{render PasswordMsg}}" />
332- </div>
333- <div class="form-group">
334- <label class="sr-only" for="reset-password-confirm">{{ render PasswordConfirmationMsg }}</label>
335- <input class="form-control" type="password" id="rp-reset-password-confirm" name="reset-password-confirm" placeholder="{{render PasswordConfirmationMsg}}" />
336- </div>
337- <div class="form-group">
338- <input class="form-control" type="submit" value="{{render ChangePasswordMsg}}" />
339- </div>
312+ <d-if cond="(_passwordChanged model)">
313+ <div></div>
314+ <div>
315+ <div class="form-group">
316+ <label class="sr-only" for="reset-password">{{ render PasswordMsg }}</label>
317+ <input class="form-control" type="password" id="rp-reset-password" name="reset-password" placeholder="{{render PasswordMsg}}" />
318+ </div>
319+ <div class="form-group">
320+ <label class="sr-only" for="reset-password-confirm">{{ render PasswordConfirmationMsg }}</label>
321+ <input class="form-control" type="password" id="rp-reset-password-confirm" name="reset-password-confirm" placeholder="{{render PasswordConfirmationMsg}}" />
322+ </div>
323+ <div class="form-group">
324+ <input class="form-control" type="submit" value="{{render ChangePasswordMsg}}" />
325+ </div>
326+ </div>
327+ </d-if>
340328 </form>
341329 </div>
342330 |]
@@ -703,7 +691,7 @@ requestResetAjaxHandler modelTV xhr rrpSubmit e =
703691 ajaxHandler modelTV handler xhr e
704692 where
705693 handler jr =
706- do -- debugStrLn $ "requestResetPasswordAjaxHandler - " ++ show jr
694+ do debugStrLn $ " requestResetPasswordAjaxHandler - " ++ show jr
707695 case _jrStatus jr of
708696 NotOk ->
709697 case _jrData jr of
@@ -713,7 +701,7 @@ requestResetAjaxHandler modelTV xhr rrpSubmit e =
713701 setProperty rrpSubmit " disabled" False
714702 doRedraws modelTV
715703 Ok ->
716- do -- debugStrLn "requestResetPasswordAjaxHandler - cake"
704+ do debugStrLn " requestResetPasswordAjaxHandler - cake"
717705 case _jrData jr of
718706 (String msg) ->
719707 do atomically $ modifyTVar' modelTV $ \ m ->
@@ -764,6 +752,7 @@ resetAjaxHandler modelTV xhr e =
764752 (String msg) ->
765753 do atomically $ modifyTVar' modelTV $ \ m ->
766754 m & resetPasswordMsg .~ (Text. unpack msg)
755+ & passwordChanged .~ True
767756 doRedraws modelTV
768757
769758 pure ()
0 commit comments