mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-03-05 11:30:46 +08:00
feat: 各种登录方式传入invite_token
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
<!-- pages/github-callback.vue -->
|
||||
<template>
|
||||
<CallbackPage />
|
||||
</template>
|
||||
@@ -8,9 +9,31 @@ import { githubExchange } from '~/utils/github'
|
||||
|
||||
onMounted(async () => {
|
||||
const url = new URL(window.location.href)
|
||||
const code = url.searchParams.get('code')
|
||||
const state = url.searchParams.get('state')
|
||||
const result = await githubExchange(code, state, '')
|
||||
const code = url.searchParams.get('code') || ''
|
||||
const state = url.searchParams.get('state') || ''
|
||||
|
||||
// 从 state 中解析 invite_token(githubAuthorize 已把它放进 state)
|
||||
let inviteToken = ''
|
||||
if (state) {
|
||||
try {
|
||||
const s = new URLSearchParams(state)
|
||||
inviteToken = s.get('invite_token') || s.get('invitetoken') || ''
|
||||
} catch {}
|
||||
}
|
||||
// 兜底:也支持直接跟在回调URL的查询参数上
|
||||
// if (!inviteToken) {
|
||||
// inviteToken =
|
||||
// url.searchParams.get('invite_token') ||
|
||||
// url.searchParams.get('invitetoken') ||
|
||||
// ''
|
||||
// }
|
||||
|
||||
if (!code) {
|
||||
navigateTo('/login', { replace: true })
|
||||
return
|
||||
}
|
||||
|
||||
const result = await githubExchange(code, inviteToken, '')
|
||||
|
||||
if (result.needReason) {
|
||||
navigateTo(`/signup-reason?token=${result.token}`, { replace: true })
|
||||
|
||||
Reference in New Issue
Block a user