mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-12-05 12:34:08 +01:00
Improved code
This commit is contained in:
@@ -10,22 +10,16 @@ import repository from '@/api/repository'
|
||||
import accountApi from '@/api/account'
|
||||
import accountsApi from '@/api/accounts'
|
||||
import authApi from '@/api/auth.js'
|
||||
|
||||
import { getAbsoluteUrl } from '@/utils'
|
||||
import { useGlobalConfig } from '@/main'
|
||||
|
||||
export const useAuthStore = defineStore('auth', () => {
|
||||
const config = useGlobalConfig()
|
||||
const authUser = ref(null)
|
||||
const isAuthenticated = ref(false)
|
||||
let redirectUri = config.OAUTH_REDIRECT_URI
|
||||
let postLogoutRedirectUri = config.OAUTH_POST_REDIRECT_URI
|
||||
let redirectUri = getAbsoluteUrl(config.OAUTH_REDIRECT_URI)
|
||||
let postLogoutRedirectUri = getAbsoluteUrl(config.OAUTH_POST_REDIRECT_URI)
|
||||
|
||||
if (!redirectUri.startsWith('http')) {
|
||||
redirectUri = `${location.protocol}//${location.host}${config.OAUTH_REDIRECT_URI}`
|
||||
}
|
||||
if (!postLogoutRedirectUri.startsWith('http')) {
|
||||
postLogoutRedirectUri = `${location.protocol}//${location.host}${config.OAUTH_POST_REDIRECT_URI}`
|
||||
}
|
||||
const manager = new UserManager({
|
||||
authority: config.OAUTH_AUTHORITY_URL,
|
||||
client_id: config.OAUTH_CLIENT_ID,
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
function getAbsoluteUrl(url) {
|
||||
if (!url.startsWith('http')) {
|
||||
return `${location.protocol}//${location.host}${url}`
|
||||
}
|
||||
return url
|
||||
}
|
||||
|
||||
export { getAbsoluteUrl }
|
||||
Reference in New Issue
Block a user