Make first factor login page UI indicate loading state

* Submit button changes to "Loading..."
* Form fades and disables
This commit is contained in:
Callan Bryant 2018-07-19 14:58:06 +01:00
parent f67bb69ee0
commit 9cd48c068d
4 changed files with 12 additions and 4 deletions

View File

@ -1,3 +1,4 @@
export const USERNAME_FIELD_ID = "#username";
export const PASSWORD_FIELD_ID = "#password";
export const SIGN_IN_BUTTON_ID = "#signin";

View File

@ -15,7 +15,10 @@ export default function (window: Window, $: JQueryStatic,
function onFormSubmitted() {
const username: string = $(UISelectors.USERNAME_FIELD_ID).val() as string;
const password: string = $(UISelectors.PASSWORD_FIELD_ID).val() as string;
$(UISelectors.PASSWORD_FIELD_ID).val("");
$("form").css("opacity", 0.5);
$("input,button").attr("disabled", "true");
$(UISelectors.SIGN_IN_BUTTON_ID).text("Please wait...");
const redirectUrl = QueryParametersRetriever.get(Constants.REDIRECT_QUERY_PARAM);
firstFactorValidator.validate(username, password, redirectUrl, $)
@ -29,6 +32,10 @@ export default function (window: Window, $: JQueryStatic,
function onFirstFactorFailure(err: Error) {
notifier.error(UserMessages.AUTHENTICATION_FAILED);
$(UISelectors.PASSWORD_FIELD_ID).select();
$("form").css("opacity", 1);
$("input,button").removeAttr("disabled");
$(UISelectors.SIGN_IN_BUTTON_ID).text("Sign in");
}
$(window.document).ready(function () {

View File

@ -14,7 +14,7 @@ block content
div(class="form-inputs")
input(type="text" class="form-control" id="username" placeholder="Username" required autofocus)
input(type="password" class="form-control" id="password" placeholder="Password" required)
button(class="btn btn-lg btn-primary btn-block" type="submit") Sign in
button(id="signin" class="btn btn-lg btn-primary btn-block" type="submit") Sign in
div(class="bottom-right-links pull-right")
a(href=reset_password_request_endpoint, class="link forgot-password") Forgot password?
span(class="clearfix")