修复申请原因可能为空的bug

This commit is contained in:
WilliamColton
2025-08-04 18:36:32 +08:00
parent 6fa5978613
commit 3b82a4aba0
2 changed files with 7 additions and 7 deletions
@@ -155,7 +155,7 @@ public class AuthController {
)); ));
} }
if (req.reason == null || req.reason.length() <= 20) { if (req.reason == null || req.reason.trim().length() <= 20) {
return ResponseEntity.badRequest().body(Map.of( return ResponseEntity.badRequest().body(Map.of(
"error", "Reason's length must longer than 20", "error", "Reason's length must longer than 20",
"reason_code", "INVALID_CREDENTIALS" "reason_code", "INVALID_CREDENTIALS"
+6 -6
View File
@@ -6,7 +6,7 @@
为了我们社区的良性发展请填写注册理由我们将根据你的理由审核你的注册, 谢谢! 为了我们社区的良性发展请填写注册理由我们将根据你的理由审核你的注册, 谢谢!
</div> </div>
<div class="reason-input-container"> <div class="reason-input-container">
<BaseInput textarea rows="4" v-model="reason" placeholder="20个字以上" ></BaseInput> <BaseInput textarea rows="4" v-model="reason" placeholder="20个字以上"></BaseInput>
<div class="char-count">{{ reason.length }}/20</div> <div class="char-count">{{ reason.length }}/20</div>
</div> </div>
<div v-if="error" class="error-message">{{ error }}</div> <div v-if="error" class="error-message">{{ error }}</div>
@@ -18,11 +18,11 @@
<script> <script>
import BaseInput from '../components/BaseInput.vue' import BaseInput from '../components/BaseInput.vue'
import { API_BASE_URL, toast } from '../main' import {API_BASE_URL, toast} from '../main'
export default { export default {
name: 'SignupReasonPageView', name: 'SignupReasonPageView',
components: { BaseInput }, components: {BaseInput},
data() { data() {
return { return {
reason: '', reason: '',
@@ -34,12 +34,12 @@ export default {
mounted() { mounted() {
this.token = this.$route.query.token || '' this.token = this.$route.query.token || ''
if (!this.token) { if (!this.token) {
this.$router.push('/signup') this.$router.push('/signup')
} }
}, },
methods: { methods: {
async submit() { async submit() {
if (!this.reason || this.reason.length < 20) { if (!this.reason || this.reason.trim().length < 20) {
this.error = '请至少输入20个字' this.error = '请至少输入20个字'
return return
} }
@@ -48,7 +48,7 @@ export default {
this.isWaitingForRegister = true this.isWaitingForRegister = true
const res = await fetch(`${API_BASE_URL}/api/auth/reason`, { const res = await fetch(`${API_BASE_URL}/api/auth/reason`, {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
body: JSON.stringify({ body: JSON.stringify({