show/hide password button
This commit is contained in:
@@ -30,6 +30,7 @@ use crate::webauthn::WebAuthnService;
|
||||
const STYLE_CSS: &[u8] = include_bytes!("../static/style.css");
|
||||
const PASSKEY_LOGIN_JS: &[u8] = include_bytes!("../static/passkey-login.js");
|
||||
const PASSKEY_REGISTER_JS: &[u8] = include_bytes!("../static/passkey-register.js");
|
||||
const PASSWORD_TOGGLE_JS: &[u8] = include_bytes!("../static/password-toggle.js");
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AppState {
|
||||
@@ -323,6 +324,7 @@ async fn static_asset(Path(path): Path<String>) -> Response {
|
||||
"style.css" => ("text/css", STYLE_CSS),
|
||||
"passkey-login.js" => ("application/javascript", PASSKEY_LOGIN_JS),
|
||||
"passkey-register.js" => ("application/javascript", PASSKEY_REGISTER_JS),
|
||||
"password-toggle.js" => ("application/javascript", PASSWORD_TOGGLE_JS),
|
||||
_ => return StatusCode::NOT_FOUND.into_response(),
|
||||
};
|
||||
([(header::CONTENT_TYPE, mime)], data).into_response()
|
||||
|
||||
+19
-4
@@ -25,13 +25,17 @@ pub fn login_page(error: Option<&str>, invite: Option<&str>) -> Markup {
|
||||
label for="email" { "Email" }
|
||||
input id="email" name="email" type="email" autocomplete="email" autofocus;
|
||||
label for="password" { "Password" }
|
||||
input id="password" name="password" type="password" autocomplete="current-password" required;
|
||||
div class="password-field" {
|
||||
input id="password" name="password" type="password" autocomplete="current-password" required;
|
||||
button class="password-toggle" type="button" data-toggle-for="password" aria-label="Show password" { "Show" }
|
||||
}
|
||||
button class="button button-primary" type="submit" { "Sign in" }
|
||||
}
|
||||
div class="auth-divider" { span { "or" } }
|
||||
button id="passkey-login" class="button button-secondary" type="button" { "Sign in with a passkey" }
|
||||
p class="auth-switch" { "Need an account? " a href="/register" { "Create one" } }
|
||||
}
|
||||
script src="/static/password-toggle.js" {}
|
||||
script src="/static/passkey-login.js" {}
|
||||
},
|
||||
)
|
||||
@@ -58,11 +62,15 @@ pub fn register_page(error: Option<&str>, invite: Option<&str>) -> Markup {
|
||||
label for="email" { "Email" }
|
||||
input id="email" name="email" type="email" autocomplete="email" required;
|
||||
label for="password" { "Password" }
|
||||
input id="password" name="password" type="password" autocomplete="new-password" required;
|
||||
div class="password-field" {
|
||||
input id="password" name="password" type="password" autocomplete="new-password" required;
|
||||
button class="password-toggle" type="button" data-toggle-for="password" aria-label="Show password" { "Show" }
|
||||
}
|
||||
button class="button button-primary" type="submit" { "Create account" }
|
||||
}
|
||||
p class="auth-switch" { "Already have an account? " a href="/login" { "Sign in" } }
|
||||
}
|
||||
script src="/static/password-toggle.js" {}
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -141,13 +149,20 @@ pub fn account_page(
|
||||
form method="post" action="/account/password" class="stack" {
|
||||
input type="hidden" name="csrf" value=(csrf_token);
|
||||
label for="new-password" { "New password" }
|
||||
input id="new-password" name="new_password" type="password" autocomplete="new-password" required;
|
||||
div class="password-field" {
|
||||
input id="new-password" name="new_password" type="password" autocomplete="new-password" required;
|
||||
button class="password-toggle" type="button" data-toggle-for="new-password" aria-label="Show password" { "Show" }
|
||||
}
|
||||
label for="confirm-password" { "Confirm new password" }
|
||||
input id="confirm-password" name="confirm_password" type="password" autocomplete="new-password" required;
|
||||
div class="password-field" {
|
||||
input id="confirm-password" name="confirm_password" type="password" autocomplete="new-password" required;
|
||||
button class="password-toggle" type="button" data-toggle-for="confirm-password" aria-label="Show password" { "Show" }
|
||||
}
|
||||
button class="button button-primary" type="submit" { "Update password" }
|
||||
}
|
||||
}
|
||||
}
|
||||
script src="/static/password-toggle.js" {}
|
||||
script src="/static/passkey-register.js" {}
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user