vikunja-frontend/src/helpers/redirectToProvider.ts
Dominik Pschenitschni 35c861b711
feat: create randomId helper and use everywhere
Co-authored-by: konrad <konrad@kola-entertainments.de>
2021-10-11 18:08:32 +02:00

15 lines
474 B
TypeScript

import {createRandomID} from '@/helpers/randomId'
interface Provider {
name: string
key: string
authUrl: string
clientId: string
}
export const redirectToProvider = (provider: Provider, redirectUrl: string) => {
const state = createRandomID(24)
localStorage.setItem('state', state)
window.location.href = `${provider.authUrl}?client_id=${provider.clientId}&redirect_uri=${redirectUrl}${provider.key}&response_type=code&scope=openid email profile&state=${state}`
}