Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Umbraco.Web.UI.Login/public/closedEye.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/Umbraco.Web.UI.Login/public/openEye.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 16 additions & 25 deletions src/Umbraco.Web.UI.Login/src/auth.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import { UmbSlimBackofficeController } from './controllers';
// We import the authStyles here so that we can inline it in the shadow DOM that is created outside of the UmbAuthElement.
import authStyles from './auth-styles.css?inline';

// Import the SVG files
import openEyeSVG from '../public/openEye.svg?raw';
import closedEyeSVG from '../public/closedEye.svg?raw';

// Import the main bundle
import { extensions } from './umbraco-package.js';

Expand Down Expand Up @@ -48,21 +52,6 @@ const createShowPasswordToggleButton = (opts: {
ariaLabelShowPassword: string;
ariaLabelHidePassword: string;
}) => {
const openEyeSVG = `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"></path>
<circle cx="12" cy="12" r="3"></circle>
</svg>
`;
const closedEyeSVG = `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"></path>
<path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"></path>
<path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"></path>
<line x1="2" x2="22" y1="2" y2="22"></line>
</svg>
`;

const button = document.createElement('button');
button.id = opts.id;
button.ariaLabel = opts.ariaLabelShowPassword;
Expand Down Expand Up @@ -216,22 +205,24 @@ export default class UmbAuthElement extends UmbLitElement {
}

async #waitForLocalization(): Promise<void> {
return new Promise((resolve) => {
// Check if localization is already available
if (this.localize.term('auth_showPassword') !== 'auth_showPassword') {
resolve();
return;
}

return new Promise((resolve, reject) => {
let retryCount = 0;
// Retries 40 times with a 50ms interval = 2 seconds
const maxRetries = 40;

// If not, we check periodically until it is available or we reach the max retries
// We check periodically until it is available or we reach the max retries
const checkInterval = setInterval(() => {
if (this.localize.term('auth_showPassword') !== 'auth_showPassword' || retryCount >= maxRetries) {
// If we reach max retries, we give up and reject the promise
if (retryCount > maxRetries) {
clearInterval(checkInterval);
reject('Localization not available');
return;
}
// Check if localization is available
if (this.localize.term('auth_showPassword') !== 'auth_showPassword') {
clearInterval(checkInterval);
resolve();
return;
}
retryCount++;
}, 50);
Expand Down Expand Up @@ -294,7 +285,7 @@ export default class UmbAuthElement extends UmbLitElement {
this._passwordLayoutItem = createFormLayoutPasswordItem(
this._passwordLabel,
this._passwordInput,
this._passwordShowPassswordToggleItem
this._passwordShowPasswordToggleItem
);

this._form = createForm([this._usernameLayoutItem, this._passwordLayoutItem]);
Expand Down