fix: store username during login to fix password change 401 error (addresses #396)

This commit is contained in:
Pulse Monitor
2025-09-04 14:18:30 +00:00
parent 75d6bb59ce
commit 35f5de75bd
2 changed files with 6 additions and 5 deletions
@@ -13,9 +13,6 @@ export const ChangePasswordModal: Component<ChangePasswordModalProps> = (props)
const [confirmPassword, setConfirmPassword] = createSignal('');
const [loading, setLoading] = createSignal(false);
const [error, setError] = createSignal('');
// Debug logging
console.log('ChangePasswordModal rendered, isOpen:', props.isOpen);
const handleSubmit = async (e: Event) => {
e.preventDefault();
@@ -46,8 +43,8 @@ export const ChangePasswordModal: Component<ChangePasswordModalProps> = (props)
.find(row => row.startsWith('pulse_csrf='))
?.split('=')[1];
// Get the actual username from localStorage or use 'admin' as fallback
const authUser = localStorage.getItem('authUser') || 'admin';
// Get the actual username from sessionStorage or use 'admin' as fallback
const authUser = sessionStorage.getItem('pulse_auth_user') || 'admin';
const headers: Record<string, string> = {
'Content-Type': 'application/json',
'Authorization': `Basic ${btoa(`${authUser}:${currentPassword()}`)}`,
+4
View File
@@ -57,6 +57,9 @@ class ApiClient {
type: 'basic',
value: this.authHeader
}));
// Also store username for password change functionality
sessionStorage.setItem('pulse_auth_user', username);
}
// Set API token
@@ -75,6 +78,7 @@ class ApiClient {
this.authHeader = null;
this.apiToken = null;
sessionStorage.removeItem('pulse_auth');
sessionStorage.removeItem('pulse_auth_user');
}
// Check if we have any auth configured