Bläddra i källkod

fix: 修复验证码读取失败

fanyanpeng 2 år sedan
förälder
incheckning
f99caa1a7f
1 ändrade filer med 5 tillägg och 1 borttagningar
  1. 5 1
      server/controller/user.js

+ 5 - 1
server/controller/user.js

@@ -136,6 +136,7 @@ class UserController {
    */
   static async register(ctx) {
     const { name, password, phone, email, identifyCode } = ctx.request.body;
+
     let curUser = null;
     try{
       curUser = await getTokenUser(ctx);
@@ -144,6 +145,8 @@ class UserController {
     }
 
     try {
+      console.log(ctx.request.body)
+      console.log(identifyCode)
       if (curUser === null || curUser.role === "STUDENT"){  // 普通用户注册流程
         UserController.validateIdentifyCode(ctx,identifyCode,phone)  //需要验证手机验证码
         ctx.session.verification_phone = undefined;
@@ -174,7 +177,7 @@ class UserController {
     }
   }
 
-  static validateIdentifyCode(ctx,idetifyCode,phone){
+  static validateIdentifyCode(ctx,identifyCode,phone){
     if (!ctx.session.verification_phone || !ctx.session.verification_code) {
       throw new Error('请重新获取验证码')
     }
@@ -182,6 +185,7 @@ class UserController {
     if (ctx.session.verification_code !== identifyCode || ctx.session.verification_phone !== phone) {
       throw new Error('验证码错误');
     }
+    console.log('验证成功',ctx.session.verification_code,ctx.session.verification_phone)
   }
 
   // 验证注册数据是否合法