24 lines
733 B
JavaScript
24 lines
733 B
JavaScript
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) {
|
|
return renderView('account/password', {
|
|
title: 'My account',
|
|
active: 'account',
|
|
currentUser: currentUser || null,
|
|
message: message || '',
|
|
username: currentUser ? currentUser.username : '',
|
|
name: currentUser ? String(currentUser.name || '') : '',
|
|
returnUrl: normalizeReturnUrl(returnUrl)
|
|
});
|
|
}; |