mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-06-09 11:39:31 +08:00
feat: auth config
This commit is contained in:
@@ -26,7 +26,7 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
hideMenu() {
|
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>
|
<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>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { githubExchange } from '../utils/github'
|
import { githubExchange } from '../utils/github'
|
||||||
|
import { hatch } from 'ldrs'
|
||||||
|
hatch.register()
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'GithubCallbackPageView',
|
name: 'GithubCallbackPageView',
|
||||||
@@ -23,11 +29,19 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.loading {
|
.github-callback-page {
|
||||||
|
background-color: var(--background-color);
|
||||||
height: calc(100vh - var(--header-height));
|
height: calc(100vh - var(--header-height));
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: 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>
|
</style>
|
||||||
|
|||||||
@@ -77,9 +77,11 @@ export default {
|
|||||||
} else if (data.reason_code === 'NOT_VERIFIED') {
|
} else if (data.reason_code === 'NOT_VERIFIED') {
|
||||||
toast.info('当前邮箱未验证,已经为您重新发送验证码')
|
toast.info('当前邮箱未验证,已经为您重新发送验证码')
|
||||||
this.$router.push({ path: '/signup', query: { verify: 1, u: this.username } })
|
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('您的注册正在审批中, 请留意邮件')
|
toast.info('您的注册正在审批中, 请留意邮件')
|
||||||
this.$router.push('/')
|
this.$router.push('/')
|
||||||
|
} else if (data.reason_code === 'NOT_APPROVED') {
|
||||||
|
this.$router.push('/signup-reason?token=' + data.token)
|
||||||
} else {
|
} else {
|
||||||
toast.error(data.error || '登录失败')
|
toast.error(data.error || '登录失败')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,12 @@ public class AuthController {
|
|||||||
"user_name", user.getUsername()));
|
"user_name", user.getUsername()));
|
||||||
}
|
}
|
||||||
if (RegisterMode.WHITELIST.equals(registerModeService.getRegisterMode()) && !user.isApproved()) {
|
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(
|
return ResponseEntity.badRequest().body(Map.of(
|
||||||
"error", "Register reason not approved",
|
"error", "Register reason not approved",
|
||||||
"reason_code", "NOT_APPROVED",
|
"reason_code", "NOT_APPROVED",
|
||||||
@@ -112,12 +118,14 @@ public class AuthController {
|
|||||||
if (user.get().getRegisterReason() != null && !user.get().getRegisterReason().isEmpty()) {
|
if (user.get().getRegisterReason() != null && !user.get().getRegisterReason().isEmpty()) {
|
||||||
return ResponseEntity.badRequest().body(Map.of(
|
return ResponseEntity.badRequest().body(Map.of(
|
||||||
"error", "Account awaiting approval",
|
"error", "Account awaiting approval",
|
||||||
"reason_code", "IS_APPROVING"
|
"reason_code", "IS_APPROVING",
|
||||||
|
"token", jwtService.generateReasonToken(user.get().getUsername())
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
return ResponseEntity.badRequest().body(Map.of(
|
return ResponseEntity.badRequest().body(Map.of(
|
||||||
"error", "Account awaiting approval",
|
"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