support at.syu.is oauth

This commit is contained in:
2026-02-16 04:51:20 +09:00
parent 5e84ba7b1d
commit 799f7145f8
4 changed files with 31 additions and 22 deletions

View File

@@ -65,8 +65,17 @@ async function initOAuthClient(): Promise<BrowserOAuthClient> {
return oauthClient
}
// Primary OAuth domain
const OAUTH_ORIGIN = 'https://syui.ai'
// Login with handle
export async function login(handle: string): Promise<void> {
// Redirect to primary OAuth domain if on a different domain
if (window.location.origin !== OAUTH_ORIGIN) {
window.location.href = `${OAUTH_ORIGIN}${window.location.pathname}?login=${encodeURIComponent(handle)}`
return
}
await setNetworkConfig(handle)
try {

View File

@@ -91,6 +91,16 @@ async function render(route: Route): Promise<void> {
await handleCallback()
}
// Auto-login if redirected from another domain with ?login=handle
if (oauthEnabled && searchParams.has('login')) {
const loginHandle = searchParams.get('login')
if (loginHandle) {
window.history.replaceState({}, '', window.location.pathname)
await login(loginHandle)
return
}
}
// Restore session from storage (skip if oauth disabled)
if (oauthEnabled) {
await restoreSession()