mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-22 19:23:31 +00:00
fix: store username during login to fix password change 401 error (addresses #396)
This commit is contained in:
@@ -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()}`)}`,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user