Files
pulse-signage/src/web/routes/account/password.js
T
lzstealth 98f969ca0f
Publish Docker Image / build-and-push-existing-registry (./build/Dockerfile, web, pulse-signage-web) (push) Successful in 1m47s
Publish Docker Image / build-and-push-existing-registry (./build/Dockerfile.player, player, pulse-signage-player) (push) Successful in 31s
Release v2.11.1
2026-09-04 15:43:55 +01:00

54 lines
2.4 KiB
JavaScript

// Account password page renderer and return URL normalization.
const { renderView } = require('../../view');
function normalizeReturnUrl(value) {
const url = String(value || '').trim();
if (!url || url === '/account' || url.indexOf('/account?') === 0) {
return '/dashboard';
}
if (!/^\/(?:account|dashboard)(?:\/|\?|$)/.test(url)) {
return '/dashboard';
}
return url;
}
module.exports = function renderAccountPage(currentUser, message, returnUrl, allowUserSessionRevocation, sessions, passwordRequirements) {
const requirements = passwordRequirements || {
minimumLength: 10,
minimumCategories: 3,
requireLowercase: false,
requireUppercase: false,
requireNumber: false,
requireSymbol: false
};
const requiredCategories = [];
if (requirements.requireLowercase) requiredCategories.push('lowercase');
if (requirements.requireUppercase) requiredCategories.push('uppercase');
if (requirements.requireNumber) requiredCategories.push('number');
if (requirements.requireSymbol) requiredCategories.push('symbol');
const passwordRequirementsText = requiredCategories.length
? 'Use at least ' + requirements.minimumLength + ' characters and include ' + requiredCategories.join(', ') + '.'
: requirements.minimumCategories === 4
? 'Use at least ' + requirements.minimumLength + ' characters and include uppercase, lowercase, number, and symbol.'
: 'Use at least ' + requirements.minimumLength + ' characters and include ' + requirements.minimumCategories + ' of: uppercase, lowercase, number, and symbol.';
return renderView('account/index', {
title: 'My account',
active: 'account',
currentUser: currentUser || null,
message: message || '',
username: currentUser ? currentUser.username : '',
name: currentUser ? String(currentUser.name || '') : '',
email: currentUser ? String(currentUser.email || '') : '',
emailPending: Boolean(currentUser && currentUser.pending_email),
pendingEmail: currentUser ? String(currentUser.pending_email || '') : '',
emailVerified: Boolean(currentUser && currentUser.email_verified_at),
returnUrl: normalizeReturnUrl(returnUrl),
allowUserSessionRevocation: Boolean(allowUserSessionRevocation),
sessions: Array.isArray(sessions) ? sessions : [],
passwordMinimumLength: requirements.minimumLength,
passwordRequirementsText: passwordRequirementsText,
scripts: ['js/account/account-page.js']
});
};