👽 Update to latest Passport version

This commit is contained in:
LittleSheep 2024-09-16 11:21:53 +08:00
parent 010f8a065b
commit 7375c6a774
7 changed files with 50 additions and 38 deletions

View File

@ -1,11 +1,15 @@
<template> <template>
<div class="flex items-center"> <div class="flex items-center">
<v-form class="flex-grow-1" @submit.prevent="submit"> <v-form class="flex-grow-1" @submit.prevent="submit">
<v-text-field :label="t('username')" variant="solo" density="comfortable" class="mb-3" :hide-details="true" <v-text-field
:disabled="props.loading" v-model="probe" /> :label="t('username')"
<v-text-field :label="t('password')" variant="solo" density="comfortable" type="password" variant="solo"
:disabled="props.loading" density="comfortable"
v-model="password" /> class="mb-3"
:hide-details="true"
:disabled="props.loading"
v-model="probe"
/>
<v-expand-transition> <v-expand-transition>
<v-alert v-show="error" variant="tonal" type="error" class="text-xs mb-3"> <v-alert v-show="error" variant="tonal" type="error" class="text-xs mb-3">
@ -36,7 +40,6 @@ const { t } = useI18n()
const config = useRuntimeConfig() const config = useRuntimeConfig()
const probe = ref("") const probe = ref("")
const password = ref("")
const error = ref<string | null>(null) const error = ref<string | null>(null)
@ -44,13 +47,13 @@ const props = defineProps<{ loading?: boolean }>()
const emits = defineEmits(["swap", "update:loading", "update:ticket"]) const emits = defineEmits(["swap", "update:loading", "update:ticket"])
async function submit() { async function submit() {
if (!probe.value || !password.value) return if (!probe.value) return
emits("update:loading", true) emits("update:loading", true)
const res = await fetch(`${config.public.solarNetworkApi}/cgi/id/auth`, { const res = await fetch(`${config.public.solarNetworkApi}/cgi/id/auth`, {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ username: probe.value, password: password.value }), body: JSON.stringify({ username: probe.value }),
}) })
if (res.status !== 200) { if (res.status !== 200) {
error.value = await res.text() error.value = await res.text()

View File

@ -58,8 +58,8 @@ const emits = defineEmits(["swap", "update:ticket", "update:loading"])
async function submit() { async function submit() {
emits("update:loading", true) emits("update:loading", true)
const res = await fetch(`${config.public.solarNetworkApi}/cgi/id/auth/mfa`, { const res = await fetch(`${config.public.solarNetworkApi}/cgi/id/auth`, {
method: "POST", method: "PATCH",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ body: JSON.stringify({
ticket_id: props.ticket?.id, ticket_id: props.ticket?.id,

View File

@ -48,7 +48,7 @@ async function load() {
if (res.status !== 200) { if (res.status !== 200) {
error.value = await res.text() error.value = await res.text()
} else { } else {
factors.value = (await res.json()).filter((e: any) => e.type != 0) factors.value = await res.json()
} }
emits("update:loading", false) emits("update:loading", false)
} }
@ -76,13 +76,15 @@ async function submit() {
function getFactorType(item: any) { function getFactorType(item: any) {
switch (item.type) { switch (item.type) {
case 0:
return { icon: "mdi-form-textbox-password", label: t("multiFactorTypePassword") }
case 1: case 1:
return { icon: "mdi-email-fast", label: t('multiFactorTypeEmail') } return { icon: "mdi-email-fast", label: t("multiFactorTypeEmail") }
} }
} }
function getFactorAvailable(factor: any) { function getFactorAvailable(factor: any) {
const blacklist: number[] = props.ticket?.blacklist_factors ?? [] const blacklist: number[] = props.ticket?.factor_trail ?? []
return blacklist.includes(factor.id) return blacklist.includes(factor.id)
} }
</script> </script>

View File

@ -36,6 +36,7 @@
"multiFactorCaption": "We need to verify that the person trying to access your account is you.", "multiFactorCaption": "We need to verify that the person trying to access your account is you.",
"multiFactorHint": "Check your inbox", "multiFactorHint": "Check your inbox",
"multiFactorTypeEmail": "Email One-time-password", "multiFactorTypeEmail": "Email One-time-password",
"multiFactorTypePassword": "Password",
"signInCompleted": "All Done", "signInCompleted": "All Done",
"signInCompletedCaption": "Welcome back! You just signed in right now! We're going to direct you to dashboard...", "signInCompletedCaption": "Welcome back! You just signed in right now! We're going to direct you to dashboard...",
"authorizeTitle": "Connect to third-party", "authorizeTitle": "Connect to third-party",

View File

@ -36,6 +36,7 @@
"multiFactorCaption": "我们需要验证试图访问您账户的人是您本人。", "multiFactorCaption": "我们需要验证试图访问您账户的人是您本人。",
"multiFactorHint": "检查您的收件箱", "multiFactorHint": "检查您的收件箱",
"multiFactorTypeEmail": "电子邮件一次性密码", "multiFactorTypeEmail": "电子邮件一次性密码",
"multiFactorTypePassword": "账号密码",
"signInCompleted": "完成", "signInCompleted": "完成",
"signInCompletedCaption": "欢迎回来!您刚刚登录成功!我们将引导您进入仪表板...", "signInCompletedCaption": "欢迎回来!您刚刚登录成功!我们将引导您进入仪表板...",
"transferredToSolianHint": "此部分功能已转移到我们的应用程序 Solian请下载或在浏览器中打开。如需了解更多信息请访问项目描述页面。", "transferredToSolianHint": "此部分功能已转移到我们的应用程序 Solian请下载或在浏览器中打开。如需了解更多信息请访问项目描述页面。",

View File

@ -12,15 +12,15 @@
"dependencies": { "dependencies": {
"@mdi/font": "^7.4.47", "@mdi/font": "^7.4.47",
"@nuxt/content": "^2.13.2", "@nuxt/content": "^2.13.2",
"@nuxt/image": "^1.7.0", "@nuxt/image": "^1.8.0",
"@nuxtjs/i18n": "^8.3.3", "@nuxtjs/i18n": "^8.5.3",
"@nuxtjs/sitemap": "^6.0.0-beta.1", "@nuxtjs/sitemap": "^6.0.1",
"@pinia/nuxt": "^0.5.3", "@pinia/nuxt": "^0.5.4",
"feed": "^4.2.2", "feed": "^4.2.2",
"nuxt": "^3.12.4", "nuxt": "^3.13.2",
"nuxt-gtag": "^2.1.0", "nuxt-gtag": "^2.1.0",
"nuxt-schema-org": "^3.3.9", "nuxt-schema-org": "^3.4.0",
"pinia": "^2.2.1", "pinia": "^2.2.2",
"rehype-sanitize": "^6.0.0", "rehype-sanitize": "^6.0.0",
"rehype-stringify": "^10.0.0", "rehype-stringify": "^10.0.0",
"remark": "^15.0.1", "remark": "^15.0.1",
@ -34,6 +34,6 @@
"@unocss/preset-typography": "^0.61.9", "@unocss/preset-typography": "^0.61.9",
"@unocss/reset": "^0.61.9", "@unocss/reset": "^0.61.9",
"vite-plugin-vuetify": "^2.0.4", "vite-plugin-vuetify": "^2.0.4",
"vuetify": "^3.6.14" "vuetify": "^3.7.1"
} }
} }

View File

@ -13,8 +13,13 @@
<v-window :touch="false" :model-value="panel" class="pa-2 mx-[-0.5rem]"> <v-window :touch="false" :model-value="panel" class="pa-2 mx-[-0.5rem]">
<v-window-item v-for="(k, idx) in Object.keys(panels)" :key="idx" :value="k"> <v-window-item v-for="(k, idx) in Object.keys(panels)" :key="idx" :value="k">
<component :is="panels[k]" @swap="(val: string) => (panel = val)" v-model:loading="loading" <component
v-model:currentFactor="currentFactor" v-model:ticket="ticket" /> :is="panels[k]"
@swap="(val: string) => (panel = val)"
v-model:loading="loading"
v-model:currentFactor="currentFactor"
v-model:ticket="ticket"
/>
</v-window-item> </v-window-item>
</v-window> </v-window>
</v-card-text> </v-card-text>
@ -33,12 +38,8 @@ import AuthenticateCompleted from "~/components/auth/AuthenticateCompleted.vue"
const { t } = useI18n() const { t } = useI18n()
definePageMeta({
alias: ["/auth/mfa"],
})
useHead({ useHead({
title: t('signInTitle'), title: t("signInTitle"),
}) })
const route = useRoute() const route = useRoute()
@ -66,17 +67,21 @@ onMounted(() => pickUpTicket())
const id = useUserinfo() const id = useUserinfo()
const router = useRouter() const router = useRouter()
watch(id, (value) => { watch(
if (value.isLoggedIn) { id,
if (route.query["close"]) { (value) => {
window.close() if (value.isLoggedIn) {
} else if (route.query["redirect_uri"]) { if (route.query["close"]) {
window.open((route.query["redirect_uri"] as string) ?? "/", "_self") window.close()
} else { } else if (route.query["redirect_uri"]) {
router.push("/users/me") window.open((route.query["redirect_uri"] as string) ?? "/", "_self")
} else {
router.push("/users/me")
}
} }
} },
}, { deep: true, immediate: true }) { deep: true, immediate: true },
)
const panel = ref("authenticate") const panel = ref("authenticate")