sso修复
This commit is contained in:
1 parent
76b26a49a8
commit
d95ff27ee4
7 files changed
+104
-37
No files matched your search
@@ -4,7 +4,7 @@ import { useRoute, useRouter } from 'vue-router'
|
||||
import http, { apiErrorMessage } from '../api/http'
|
||||
import { useAuthStore } from '../stores/auth'
|
||||
import { isNativeApp } from '../auth/session'
|
||||
import { openSsoLogin } from '../services/nativeAppLinks'
|
||||
import { beginNativeSsoLogin, openSsoLogin } from '../services/nativeAppLinks'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -45,8 +45,9 @@ async function loadAccount() {
|
||||
async function startBinding() {
|
||||
actionLoading.value = true
|
||||
try {
|
||||
const nativeState = beginNativeSsoLogin()
|
||||
const { data } = await http.post('/auth/sso/prepare-binding', null, {
|
||||
params: { nativeApp: isNativeApp() },
|
||||
params: { nativeApp: isNativeApp(), nativeState },
|
||||
})
|
||||
await openSsoLogin(String(data.loginUrl))
|
||||
} catch (error) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { apiErrorMessage } from '../api/http'
|
||||
import { useAuthStore } from '../stores/auth'
|
||||
import http from '../api/http'
|
||||
import { isNativeApp } from '../auth/session'
|
||||
import { openSsoLogin } from '../services/nativeAppLinks'
|
||||
import { beginNativeSsoLogin, openSsoLogin } from '../services/nativeAppLinks'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -34,9 +34,10 @@ async function startSso() {
|
||||
ssoLoading.value = true
|
||||
const apiBaseUrl = String(import.meta.env.VITE_API_BASE_URL ?? '/api').replace(/\/$/, '')
|
||||
const redirect = String(route.query.redirect ?? '/dashboard')
|
||||
const nativeState = beginNativeSsoLogin()
|
||||
try {
|
||||
await openSsoLogin(
|
||||
`${apiBaseUrl}/auth/sso/login?returnUrl=${encodeURIComponent(redirect)}&nativeApp=${isNativeApp()}`,
|
||||
`${apiBaseUrl}/auth/sso/login?returnUrl=${encodeURIComponent(redirect)}&nativeApp=${isNativeApp()}${nativeState ? `&nativeState=${encodeURIComponent(nativeState)}` : ''}`,
|
||||
)
|
||||
} catch (error) {
|
||||
ssoLoading.value = false
|
||||
|
||||
Reference in new issue
Block a user