Add redirect_url handling and adjust auth flow
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test-backend (24.x) (push) Has been cancelled
test / API tests (node env, api-test) (24.x) (push) Has been cancelled
test / puterjs (node env, vitest) (24.x) (push) Has been cancelled

Set and propagate a redirect_url for auth flows and use it when navigating after login/signup to avoid leaking sensitive data.
This commit is contained in:
jelveh
2026-02-02 00:16:35 -08:00
parent 7cce0705d3
commit 6bd64808df
4 changed files with 12 additions and 23 deletions
-18
View File
@@ -84,24 +84,6 @@ async function UIWindowAuthMe (options = {}) {
// Content area
h += '<div style="padding: 20px;">';
// Info message
h += `<div style="
background: #f0f9ff;
border: 1px solid #bae6fd;
border-radius: 8px;
padding: 12px 14px;
margin-bottom: 16px;
">`;
h += '<div style="display: flex; align-items: flex-start; gap: 10px;">';
h += `<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="#0284c7" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="flex-shrink: 0; margin-top: 1px;">
<circle cx="12" cy="12" r="10"/>
<line x1="12" y1="16" x2="12" y2="12"/>
<line x1="12" y1="8" x2="12.01" y2="8"/>
</svg>`;
h += `<p style="margin: 0; font-size: 13px; color: #0369a1; line-height: 1.5;">${i18n('authme_security_warning')}</p>`;
h += '</div>';
h += '</div>';
// Destination URL display
h += '<div style="margin-bottom: 16px;">';
h += `<label style="display: block; font-size: 12px; font-weight: 500; color: #6b7280; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;">${i18n('redirect_destination')}</label>`;
+7 -2
View File
@@ -37,6 +37,11 @@ async function UIWindowLogin (options) {
options.reload_on_success = true;
}
if ( options.redirect_url === undefined )
{
options.redirect_url = window.location.href;
}
return new Promise(async (resolve) => {
const internal_id = window.uuidv4();
@@ -364,10 +369,9 @@ async function UIWindowLogin (options) {
window.update_auth_data(data.token, data.user);
if ( options.reload_on_success ) {
sessionStorage.setItem('playChimeNextUpdate', 'yes');
window.onbeforeunload = null;
// Replace with a clean URL to prevent password leakage
const cleanUrl = window.location.origin + window.location.pathname;
const cleanUrl = options.redirect_url || window.location.origin + window.location.pathname;
window.location.replace(cleanUrl);
} else
{
@@ -471,6 +475,7 @@ async function UIWindowLogin (options) {
referrer: options.referrer,
show_close_button: options.show_close_button,
reload_on_success: options.reload_on_success,
redirect_url: options.redirect_url,
window_options: options.window_options,
send_confirmation_code: options.send_confirmation_code,
});
+3 -2
View File
@@ -44,7 +44,7 @@ function UIWindowSignup (options) {
// Form
h += '<div style="padding: 15px;">';
// title
h += `<h1 class="signup-form-title">${i18n('create_free_account')}</h1>`;
// signup form
@@ -189,6 +189,7 @@ function UIWindowSignup (options) {
const login = await UIWindowLogin({
referrer: options.referrer,
reload_on_success: options.reload_on_success,
redirect_url: options.redirect_url,
window_options: options.window_options,
show_close_button: options.show_close_button,
send_confirmation_code: options.send_confirmation_code,
@@ -308,7 +309,7 @@ function UIWindowSignup (options) {
if ( options.reload_on_success ) {
window.onbeforeunload = null;
// Replace with a clean URL to prevent sensitive data leakage
const cleanUrl = window.location.origin + window.location.pathname;
const cleanUrl = options.redirect_url || window.location.origin + window.location.pathname;
window.location.replace(cleanUrl);
} else if ( options.send_confirmation_code ) {
$(el_window).close();
+2 -1
View File
@@ -973,7 +973,7 @@ window.initgui = async function (options) {
// -------------------------------------------------------------------------------------
if ( !window.is_auth() && (!window.first_visit_ever || window.disable_temp_users) ) {
const needs_action = action === 'authme' || action === 'copyauth';
const reload_on_success = !needs_action;
const reload_on_success = needs_action;
if ( window.logged_in_users.length > 0 ) {
await UIWindowSessionList({
reload_on_success,
@@ -986,6 +986,7 @@ window.initgui = async function (options) {
reload_on_success,
send_confirmation_code: false,
show_signup_button: ( !whoarewe.disable_user_signup ),
redirect_url: needs_action ? window.location.href : undefined,
window_options: {
has_head: false,
},