mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-22 06:50:53 +08:00
feat: auth config
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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 || '登录失败')
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user