Add authentication validation on login screen load
- Add validateToken() method to userService to check if refresh token is valid - Automatically redirect to chat if user already has valid session - Show 'Checking authentication...' loading state during validation - Prevents unnecessary login if user is already authenticated - Improves UX by skipping login screen when not needed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -55,6 +55,21 @@ class UserService {
|
||||
return data.access_token;
|
||||
}
|
||||
|
||||
async validateToken(): Promise<boolean> {
|
||||
const refreshToken = localStorage.getItem("refresh_token");
|
||||
|
||||
if (!refreshToken) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
await this.refreshToken();
|
||||
return true;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async fetchWithAuth(
|
||||
url: string,
|
||||
options: RequestInit = {},
|
||||
|
||||
Reference in New Issue
Block a user