Directly redirect to the openid auth provider if that's the only auth method
This commit is contained in:
@ -189,6 +189,7 @@ export default {
|
||||
ctx.commit('authenticated', authenticated)
|
||||
if (!authenticated) {
|
||||
ctx.commit('info', null)
|
||||
ctx.dispatch('config/redirectToProviderIfNothingElseIsEnabled', null, {root: true})
|
||||
}
|
||||
|
||||
return Promise.resolve()
|
||||
@ -198,7 +199,7 @@ export default {
|
||||
if (!jwt) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
const HTTP = HTTPFactory()
|
||||
// We're not returning the promise here to prevent blocking the initial ui render if the user is
|
||||
// accessing the site with a token in local storage
|
||||
|
@ -3,6 +3,7 @@ import Vue from 'vue'
|
||||
import {CONFIG} from '../mutation-types'
|
||||
import {HTTPFactory} from '@/http-common'
|
||||
import {objectToCamelCase} from '@/helpers/case'
|
||||
import {redirectToProvider} from '../../helpers/redirectToProvider'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
@ -69,5 +70,15 @@ export default {
|
||||
})
|
||||
.catch(e => Promise.reject(e))
|
||||
},
|
||||
redirectToProviderIfNothingElseIsEnabled(ctx) {
|
||||
if (ctx.state.auth.local.enabled === false &&
|
||||
ctx.state.auth.openidConnect.enabled &&
|
||||
ctx.state.auth.openidConnect.providers &&
|
||||
ctx.state.auth.openidConnect.providers.length === 1 &&
|
||||
window.location.pathname.startsWith('/login') // Kinda hacky, but prevents an endless loop.
|
||||
) {
|
||||
redirectToProvider(ctx.state.auth.openidConnect.providers[0], ctx.state.auth.openidConnect.redirectUrl)
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
Reference in New Issue
Block a user