Fix: Ensure email change request is sent.

The email change request was failing with a 400 error. This commit addresses the issue by ensuring the email change request is correctly sent when a user updates their email in the profile dashboard.
This commit is contained in:
Tola Leng
2025-05-17 17:55:59 +08:00
parent aaee189ace
commit 78be48ffd0
5 changed files with 97 additions and 88 deletions
+6 -3
View File
@@ -60,17 +60,20 @@ export const authService = {
return pb.authStore.isValid;
},
// New method to refresh user data after updates
// Method to refresh user data after updates
async refreshUserData(): Promise<void> {
if (!pb.authStore.isValid || !pb.authStore.model) return;
try {
// Fetch the latest user data from the server
const userId = (pb.authStore.model as any).id;
console.log("Refreshing user data for ID:", userId);
// Use the getOne method directly to refresh the auth store
await pb.collection('users').getOne(userId);
// PocketBase will automatically update the authStore
console.log("User data refreshed successfully");
} catch (error) {
console.error('Failed to refresh user data:', error);
}
}
};
};