fix oauth config

This commit is contained in:
2026-01-18 20:14:49 +09:00
parent 61f7422075
commit ce00222537
6 changed files with 22 additions and 27 deletions

View File

@@ -1,12 +1,15 @@
import { isLoggedIn, getLoggedInHandle } from '../lib/auth'
export function renderHeader(currentHandle: string): string {
export function renderHeader(currentHandle: string, oauth: boolean = true): string {
const loggedIn = isLoggedIn()
const handle = getLoggedInHandle()
const loginBtn = loggedIn
? `<button type="button" class="header-btn user-btn" id="logout-btn" title="Logout">${handle || 'logout'}</button>`
: `<button type="button" class="header-btn login-btn" id="login-btn" title="Login"><img src="/icon/user.svg" alt="Login" class="login-icon"></button>`
let loginBtn = ''
if (oauth) {
loginBtn = loggedIn
? `<button type="button" class="header-btn user-btn" id="logout-btn" title="Logout">${handle || 'logout'}</button>`
: `<button type="button" class="header-btn login-btn" id="login-btn" title="Login"><img src="/icon/user.svg" alt="Login" class="login-icon"></button>`
}
return `
<header id="header">

View File

@@ -67,6 +67,9 @@ async function render(route: Route): Promise<void> {
document.title = config.title
}
// Check OAuth enabled
const oauthEnabled = config.oauth !== false
// Handle OAuth callback if present (check both ? and #)
const searchParams = new URLSearchParams(window.location.search)
const hashParams = window.location.hash ? new URLSearchParams(window.location.hash.slice(1)) : null
@@ -108,7 +111,7 @@ async function render(route: Route): Promise<void> {
if (!did) {
app.innerHTML = `
${renderHeader(handle)}
${renderHeader(handle, oauthEnabled)}
<div class="error">Could not resolve handle: ${handle}</div>
${renderFooter(handle)}
`
@@ -139,7 +142,7 @@ async function render(route: Route): Promise<void> {
const langList = Array.from(availableLangs)
// Build page
let html = renderHeader(handle)
let html = renderHeader(handle, oauthEnabled)
// Mode tabs (Blog/Browser/Post/PDS)
const activeTab = route.type === 'postpage' ? 'post' :
@@ -264,7 +267,7 @@ async function render(route: Route): Promise<void> {
} catch (error) {
console.error('Render error:', error)
app.innerHTML = `
${renderHeader(currentHandle)}
${renderHeader(currentHandle, false)}
<div class="error">Error: ${error}</div>
${renderFooter(currentHandle)}
`

View File

@@ -6,6 +6,7 @@ export interface AppConfig {
network: string
color: string
siteUrl: string
oauth?: boolean
}
export interface Networks {