feat(auth): wire up refresh token endpoint and auto-refresh
- Add POST /api/refresh-token endpoint to router - Auth store now calls refreshTokenIfNeeded on init and every hour - Token refreshes automatically when within 2 weeks of expiry
This commit is contained in:
@@ -32,6 +32,12 @@ class AuthStore {
|
||||
constructor() {
|
||||
if (browser) {
|
||||
this.initializeAuth();
|
||||
// Check token refresh every hour
|
||||
setInterval(() => {
|
||||
if (this.token) {
|
||||
this.refreshTokenIfNeeded();
|
||||
}
|
||||
}, 60 * 60 * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +76,8 @@ class AuthStore {
|
||||
lastName: ''
|
||||
};
|
||||
this.fetchUserProfile();
|
||||
// Check if token needs refresh
|
||||
this.refreshTokenIfNeeded();
|
||||
} else {
|
||||
this.clearAuth();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user