feat(frontend): login with center URL and consume center-issued guild tokens
This commit is contained in:
@@ -13,15 +13,15 @@ export function AuthProvider({ children }: PropsWithChildren) {
|
||||
() => ({
|
||||
session,
|
||||
isAuthed: !!session,
|
||||
login: async (email: string, password: string) => {
|
||||
const next = await loginCenter({ email, password })
|
||||
login: async (centerApiBase: string, email: string, password: string) => {
|
||||
const next = await loginCenter(centerApiBase, { email, password })
|
||||
setAuthSession(next)
|
||||
setSession(next)
|
||||
},
|
||||
logout: async () => {
|
||||
if (session?.refreshToken) {
|
||||
try {
|
||||
await logoutCenter(session.refreshToken)
|
||||
await logoutCenter(session.centerApiBase, session.refreshToken)
|
||||
} catch {
|
||||
// noop
|
||||
}
|
||||
@@ -33,7 +33,7 @@ export function AuthProvider({ children }: PropsWithChildren) {
|
||||
if (!session) return null
|
||||
if (!isAccessTokenStale(session.accessToken)) return session.accessToken
|
||||
|
||||
const refreshed = await refreshCenter(session.refreshToken)
|
||||
const refreshed = await refreshCenter(session.centerApiBase, session.refreshToken)
|
||||
const next: AuthSession = {
|
||||
...session,
|
||||
accessToken: refreshed.accessToken,
|
||||
|
||||
Reference in New Issue
Block a user