fix(auth): correctly construct redirect url from current window href
continuous-integration/drone/push Build is passing Details

This commit is contained in:
kolaente 2024-01-25 14:24:30 +01:00
parent a8df935ddb
commit 67216579bc
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 3 additions and 1 deletions

View File

@ -1,11 +1,13 @@
import {createRandomID} from '@/helpers/randomId'
import type {IProvider} from '@/types/IProvider'
import {parseURL} from 'ufo'
export const redirectToProvider = (provider: IProvider) => {
// We're not using the redirect url provided by the server to allow redirects when using the electron app.
// The implications are not quite clear yet hence the logic to pass in another redirect url still exists.
const redirectUrl = `${window.location.href.replace('/login', '')}/auth/openid/`
const url = parseURL(window.location.href)
const redirectUrl = `${url.protocol}//${url.host}/auth/openid/`
const state = createRandomID(24)
localStorage.setItem('state', state)