mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-02 20:30:10 +00:00
Add Audible region config and user password change modal
Implements configurable Audible region selection in setup and admin settings, affecting all Audible API calls and triggering data refresh on change. Adds a user-facing 'Change Password' modal in the header for local users, moving password change from admin-only to all local users via a new /api/auth/change-password endpoint. Updates documentation, API routes, and context to support these features, and removes the old admin-only password change flow.
This commit is contained in:
@@ -15,6 +15,7 @@ interface User {
|
||||
email?: string;
|
||||
role: string;
|
||||
avatarUrl?: string;
|
||||
authProvider?: string | null; // 'plex' | 'oidc' | 'local' | null
|
||||
}
|
||||
|
||||
interface AuthContextType {
|
||||
@@ -90,6 +91,24 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
setAccessToken(storedToken);
|
||||
setUser(JSON.parse(storedUser));
|
||||
scheduleTokenRefresh(storedToken);
|
||||
|
||||
// Fetch fresh user data from server to get latest fields (e.g., authProvider)
|
||||
fetch('/api/auth/me', {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${storedToken}`,
|
||||
},
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
if (data.user) {
|
||||
// Update user with fresh data from server
|
||||
setUser(data.user);
|
||||
localStorage.setItem('user', JSON.stringify(data.user));
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Failed to fetch fresh user data:', error);
|
||||
});
|
||||
}
|
||||
|
||||
setIsLoading(false);
|
||||
|
||||
Reference in New Issue
Block a user