mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Improved code
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"API_BASE_URL": "/api/v2/",
|
||||
"API_DOC_URL": "/api/schema-v2/swagger/",
|
||||
"OAUTH_AUTHORITY_URL": "https://localhost:8000/api/o",
|
||||
"OAUTH_CLIENT_ID": "LVQbfIIX3khWR3nDvix1u9yEGHZUxcx53bhJ7FlD",
|
||||
"OAUTH_REDIRECT_URI": "/login/logged",
|
||||
"OAUTH_POST_REDIRECT_URI": "/"
|
||||
"API_BASE_URL": "/api/v2/",
|
||||
"API_DOC_URL": "/api/schema-v2/swagger/",
|
||||
"OAUTH_AUTHORITY_URL": "https://localhost:8000/api/o",
|
||||
"OAUTH_CLIENT_ID": "LVQbfIIX3khWR3nDvix1u9yEGHZUxcx53bhJ7FlD",
|
||||
"OAUTH_REDIRECT_URI": "/login/logged",
|
||||
"OAUTH_POST_REDIRECT_URI": "/"
|
||||
}
|
||||
|
||||
@@ -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