Allow external urls for oauth redirects

This commit is contained in:
René Preuß
2023-09-12 10:54:18 +02:00
committed by GitHub
parent eff160b3c5
commit 7384a4c5ce
2 changed files with 8 additions and 8 deletions

View File

@@ -74,7 +74,7 @@ export default async (options: ComposableOptions = {
window.location.href = `${authConfig.endpoints.logout}?${params.toString()}` window.location.href = `${authConfig.endpoints.logout}?${params.toString()}`
} }
return navigateTo(authConfig.redirect.logout) return navigateTo(authConfig.redirect.logout, { external: true })
} }
const setBearerToken = async (token: string, tokenType: string, expires: number): Promise<void> => { const setBearerToken = async (token: string, tokenType: string, expires: number): Promise<void> => {

View File

@@ -25,7 +25,7 @@ export default defineNuxtPlugin(() => {
const expires = hashParams.get('expires_in') as string; const expires = hashParams.get('expires_in') as string;
await setBearerToken(token, tokenType, parseInt(expires)); await setBearerToken(token, tokenType, parseInt(expires));
return navigateTo(authConfig.redirect.home) return navigateTo(authConfig.redirect.home, { external: true })
} }
} }
@@ -44,7 +44,7 @@ export default defineNuxtPlugin(() => {
if (stateFromRequest !== stateFromCookie.value) { if (stateFromRequest !== stateFromCookie.value) {
console.warn('State mismatch', stateFromRequest, stateFromCookie.value) console.warn('State mismatch', stateFromRequest, stateFromCookie.value)
return navigateTo(authConfig.redirect.login) return navigateTo(authConfig.redirect.login, { external: true })
} }
const formData = new FormData(); const formData = new FormData();
@@ -61,13 +61,13 @@ export default defineNuxtPlugin(() => {
if (!response.ok) { if (!response.ok) {
console.warn('Failed to fetch token', response) console.warn('Failed to fetch token', response)
return navigateTo(authConfig.redirect.login) return navigateTo(authConfig.redirect.login, { external: true })
} }
const data: AccessToken = await response.json(); const data: AccessToken = await response.json();
await setBearerToken(data.access_token, data.token_type, data.expires_in) await setBearerToken(data.access_token, data.token_type, data.expires_in)
await setRefreshToken(data.refresh_token, data.token_type, authConfig.refreshToken.maxAge) await setRefreshToken(data.refresh_token, data.token_type, authConfig.refreshToken.maxAge)
return navigateTo(authConfig.redirect.home) return navigateTo(authConfig.redirect.home, { external: true })
} }
} }
@@ -77,7 +77,7 @@ export default defineNuxtPlugin(() => {
if (to.path === authConfig.redirect.callback || to.path === authConfig.redirect.callback + '/') { if (to.path === authConfig.redirect.callback || to.path === authConfig.redirect.callback + '/') {
const queryParams = new URLSearchParams(to.query.toString()); const queryParams = new URLSearchParams(to.query.toString());
if (queryParams.has('error')) { if (queryParams.has('error')) {
return navigateTo(authConfig.redirect.login) return navigateTo(authConfig.redirect.login, { external: true })
} }
if (authConfig.responseType === 'token') { if (authConfig.responseType === 'token') {
@@ -92,7 +92,7 @@ export default defineNuxtPlugin(() => {
} }
if (user.value === undefined) { if (user.value === undefined) {
return navigateTo(authConfig.redirect.login) return navigateTo(authConfig.redirect.login, { external: true })
} }
}) })
@@ -100,7 +100,7 @@ export default defineNuxtPlugin(() => {
const {user, authConfig} = await useAuth() const {user, authConfig} = await useAuth()
if (user.value !== undefined) { if (user.value !== undefined) {
return navigateTo(authConfig.redirect.home) return navigateTo(authConfig.redirect.home, { external: true })
} }
}) })
}) })