feat: auth config

This commit is contained in:
Tim
2025-07-16 15:13:39 +08:00
parent 01e9c93dfd
commit fa95328f6d
4 changed files with 31 additions and 7 deletions

View File

@@ -26,7 +26,7 @@ export default {
},
computed: {
hideMenu() {
return ['/login', '/signup', '/404', '/signup-reason'].includes(this.$route.path)
return ['/login', '/signup', '/404', '/signup-reason', '/github-callback'].includes(this.$route.path)
}
}
}

View File

@@ -1,9 +1,15 @@
<template>
<div class="loading">GitHub 登录中...</div>
<div class="github-callback-page">
<l-hatch size="28" stroke="4" speed="3.5" color="var(--primary-color)"></l-hatch>
<div class="github-callback-page-text">Magic is happening...</div>
</div>
</template>
<script>
import { githubExchange } from '../utils/github'
import { hatch } from 'ldrs'
hatch.register()
export default {
name: 'GithubCallbackPageView',
@@ -23,11 +29,19 @@ export default {
</script>
<style scoped>
.loading {
.github-callback-page {
background-color: var(--background-color);
height: calc(100vh - var(--header-height));
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: 20px;
}
.github-callback-page-text {
margin-top: 25px;
font-size: 16px;
color: var(--primary-color);
font-weight: bold;
}
</style>

View File

@@ -77,9 +77,11 @@ export default {
} else if (data.reason_code === 'NOT_VERIFIED') {
toast.info('当前邮箱未验证,已经为您重新发送验证码')
this.$router.push({ path: '/signup', query: { verify: 1, u: this.username } })
} else if (data.reason_code === 'NOT_APPROVED') {
} else if (data.reason_code === 'IS_APPROVING') {
toast.info('您的注册正在审批中, 请留意邮件')
this.$router.push('/')
} else if (data.reason_code === 'NOT_APPROVED') {
this.$router.push('/signup-reason?token=' + data.token)
} else {
toast.error(data.error || '登录失败')
}

View File

@@ -93,6 +93,12 @@ public class AuthController {
"user_name", user.getUsername()));
}
if (RegisterMode.WHITELIST.equals(registerModeService.getRegisterMode()) && !user.isApproved()) {
if (user.getRegisterReason() != null && !user.getRegisterReason().isEmpty()) {
return ResponseEntity.badRequest().body(Map.of(
"error", "Account awaiting approval",
"reason_code", "IS_APPROVING"
));
}
return ResponseEntity.badRequest().body(Map.of(
"error", "Register reason not approved",
"reason_code", "NOT_APPROVED",
@@ -112,12 +118,14 @@ public class AuthController {
if (user.get().getRegisterReason() != null && !user.get().getRegisterReason().isEmpty()) {
return ResponseEntity.badRequest().body(Map.of(
"error", "Account awaiting approval",
"reason_code", "IS_APPROVING"
"reason_code", "IS_APPROVING",
"token", jwtService.generateReasonToken(user.get().getUsername())
));
}
return ResponseEntity.badRequest().body(Map.of(
"error", "Account awaiting approval",
"reason_code", "NOT_APPROVED"
"reason_code", "NOT_APPROVED",
"token", jwtService.generateReasonToken(user.get().getUsername())
));
}