mirror of
https://github.com/System-End/spaces.git
synced 2026-04-19 21:05:16 +00:00
landing auth fix
This commit is contained in:
parent
65e544ce78
commit
3f2e7f3dba
1 changed files with 32 additions and 0 deletions
|
|
@ -24,6 +24,38 @@
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
applyTheme(get(currentTheme));
|
applyTheme(get(currentTheme));
|
||||||
|
|
||||||
|
// Check for OAuth callback before restoring session
|
||||||
|
const hash = window.location.hash.startsWith('#')
|
||||||
|
? window.location.hash.slice(1)
|
||||||
|
: window.location.hash;
|
||||||
|
const hashParams = new URLSearchParams(hash);
|
||||||
|
|
||||||
|
if (hashParams.get('oauth_success') === 'true') {
|
||||||
|
const userData = hashParams.get('user_data');
|
||||||
|
if (userData) {
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(decodeURIComponent(userData));
|
||||||
|
user = {
|
||||||
|
authorization: parsed.authorization,
|
||||||
|
username: parsed.username,
|
||||||
|
email: parsed.email,
|
||||||
|
is_admin: parsed.is_admin,
|
||||||
|
hackatime_api_key: parsed.hackatime_api_key,
|
||||||
|
hackclub_id: parsed.hackclub_id,
|
||||||
|
hackclub_verification_status: parsed.hackclub_verification_status
|
||||||
|
};
|
||||||
|
saveSession(user);
|
||||||
|
isAuthenticated = true;
|
||||||
|
loadSpaces();
|
||||||
|
window.history.replaceState({}, '', window.location.pathname);
|
||||||
|
return;
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to parse OAuth user data:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
restoreSession();
|
restoreSession();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue