diff --git a/templates/zerver/register.html b/templates/zerver/register.html index 394c128cd5..15558f05bf 100644 --- a/templates/zerver/register.html +++ b/templates/zerver/register.html @@ -143,12 +143,14 @@ Form is validated both client-side using jquery-validation (see signup.js) and s {% elif password_required %}
+
+ + +
- {% if full_name %} @@ -252,7 +254,7 @@ Form is validated both client-side using jquery-validation (see signup.js) and s
{% endif %}
- diff --git a/templates/zerver/reset_confirm.html b/templates/zerver/reset_confirm.html index 8a8c02ce38..bcd250b2cb 100644 --- a/templates/zerver/reset_confirm.html +++ b/templates/zerver/reset_confirm.html @@ -28,10 +28,12 @@
- +
+ + +
@@ -52,7 +54,7 @@ + required /> {% if form.new_password2.errors %} {% for error in form.new_password2.errors %} @@ -63,7 +65,7 @@
- +
diff --git a/web/src/bundles/portico.ts b/web/src/bundles/portico.ts index 3b94d55f9b..b502856c09 100644 --- a/web/src/bundles/portico.ts +++ b/web/src/bundles/portico.ts @@ -6,3 +6,4 @@ import "../portico/tippyjs.ts"; import "../../third/bootstrap/css/bootstrap.portico.css"; import "../../styles/portico/portico_styles.css"; import "tippy.js/dist/tippy.css"; +import "../../styles/app_variables.css"; diff --git a/web/src/portico/signup.ts b/web/src/portico/signup.ts index 82c3c486e5..47b2fe9ec8 100644 --- a/web/src/portico/signup.ts +++ b/web/src/portico/signup.ts @@ -2,6 +2,7 @@ import $ from "jquery"; import assert from "minimalistic-assert"; import {z} from "zod"; +import render_compose_limit_indicator from "../../templates/compose_limit_indicator.hbs"; import * as common from "../common.ts"; import {$t} from "../i18n.ts"; import {password_quality, password_warning} from "../password_quality.ts"; @@ -342,3 +343,49 @@ $(() => { } }); }); + +const $password_elem: JQuery = $("input#id_password"); +const $new_password1_elem: JQuery = $("input#id_new_password1"); + +if ($password_elem.length) { + $password_elem.on("input", () => { + check_overflow_password($password_elem); + }); +} + +if ($new_password1_elem.length) { + $new_password1_elem.on("input", () => { + check_overflow_password($new_password1_elem); + }); +} + +export function check_overflow_password($password_elem: JQuery): void { + const password = $password_elem.val() ?? ""; + const max_length = 100; + const remaining_characters = max_length - password.length; + + const $indicator = $password_elem.closest(".input-box").find(".limit-indicator"); + const $button = $password_elem.closest("form").find("button[type='submit']"); + + const password_too_long = password.length > max_length; + $button.prop("disabled", password_too_long); + + // Update the limit indicator + if (password_too_long) { + $indicator.addClass("over_limit"); + $indicator.html( + render_compose_limit_indicator({ + remaining_characters, + }), + ); + } else if (remaining_characters <= 20) { + $indicator.removeClass("over_limit"); + $indicator.html( + render_compose_limit_indicator({ + remaining_characters, + }), + ); + } else { + $indicator.text(""); + } +} diff --git a/web/styles/portico/portico_signin.css b/web/styles/portico/portico_signin.css index 2b48fb8532..97185d3ed1 100644 --- a/web/styles/portico/portico_signin.css +++ b/web/styles/portico/portico_signin.css @@ -1461,3 +1461,34 @@ button#register_auth_button_gitlab { margin-top: 5px; display: none; } + +#signup-button, +#reset-button { + &:disabled { + opacity: 0.5; + cursor: not-allowed; + } +} + +#reset-password-limit-indicator, +#password-limit-indicator { + &:not(:empty) { + font-size: 16px; + color: var(--color-limit-indicator); + cursor: pointer; + height: 0; + margin-right: 5px; + z-index: 10; + } + + &.over_limit { + color: var(--color-limit-indicator-over-limit); + font-weight: bold; + } +} + +.password-label-container { + display: flex; + align-items: center; + justify-content: space-between; +}