Просмотр исходного кода

fix input errors and maxlength and clear redirect_uri

Starink 6 лет назад
Родитель
Сommit
34d3d15f44
4 измененных файлов с 47 добавлено и 4 удалено
  1. 1 1
      pages/person/identification.vue
  2. 1 1
      pages/person/info.vue
  3. 39 2
      pages/register.vue
  4. 6 0
      server/controller/user.js

+ 1 - 1
pages/person/identification.vue

@@ -17,7 +17,7 @@
         </div>
         <div class="main-card__tab__item">
           真实姓名:
-          <el-input v-model="realName" class="main-card__tab__input" maxlength="20" :disabled="disabled" oninput="value=value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5\ ]/g,'')"></el-input>
+          <el-input v-model="realName" class="main-card__tab__input" maxlength="20" :disabled="disabled" compositionend="value=value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5\ ]/g,'')"></el-input>
         </div>
         <div class="main-card__tab__item">
           所属单位:

+ 1 - 1
pages/person/info.vue

@@ -15,7 +15,7 @@
           title="修改昵称"
           :visible.sync="nameDialogVisible"
           width="30%">
-          <el-input ref="name" v-model="newName" placeholder="请输入昵称, 长度为1-10个字符" maxlength="10" oninput="value=value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5\ ]/g,'')" autofocus></el-input>
+          <el-input ref="name" v-model="newName" placeholder="请输入昵称, 长度为1-10个字符" maxlength="10" compositionend="value=value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5\ ]/g,'')" autofocus></el-input>
           <span slot="footer" class="dialog-footer">
             <el-button @click="nameDialogVisible = false">取 消</el-button>
             <el-button type="primary" @click="saveName" :loading="loading">确 定</el-button>

+ 39 - 2
pages/register.vue

@@ -2,7 +2,7 @@
   <div class="page-container login-container">
     <el-card class="login-card">
       <h2 class="login-card__title login-card__item">注 册</h2>
-      <el-input ref="name" v-model="name" placeholder="请输入昵称, 长度为1-10个字符" maxlength="10" class="login-card__item" oninput="value=value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5\ ]/g,'')" autofocus></el-input>
+      <el-input ref="name" v-model="name" placeholder="请输入昵称, 长度为1-10个字符" maxlength="10" class="login-card__item" compositionend="value=value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5\ ]/g,'')" autofocus></el-input>
       <el-input ref="password" v-model="password" type="password" placeholder="请输入密码, 长度为6-20个字符" maxlength="20" class="login-card__item"></el-input>
       <el-input ref="passwordConfirm" v-model="passwordConfirm" type="password" placeholder="请再次输入密码" maxlength="20" class="login-card__item"></el-input>
       <el-input ref="email" v-model="email" placeholder="请输入邮箱" maxlength="320" class="login-card__item" autofocus></el-input>
@@ -94,6 +94,15 @@
           this.$refs.name.focus();
           return false;
         }
+        if(this.name.length > 10){
+          this.$message({
+            showClose: true,
+            message: '昵称过长',
+            type: 'error'
+          });
+          this.$refs.name.focus();
+          return false;
+        }
 
         if(this.password.length < 6){
           if(this.password.length === 0){
@@ -112,6 +121,15 @@
           this.$refs.password.focus();
           return false;
         }
+        if(this.password.length > 10){
+          this.$message({
+            showClose: true,
+            message: '密码过长',
+            type: 'error'
+          });
+          this.$refs.password.focus();
+          return false;
+        }
 
         if(this.passwordConfirm !== this.password){
           this.$message({
@@ -132,6 +150,15 @@
           this.$refs.email.focus();
           return false;
         }
+        if(this.email.length > 255){
+          this.$message({
+            showClose: true,
+            message: '邮箱过长',
+            type: 'error'
+          });
+          this.$refs.email.focus();
+          return false;
+        }
 
         const myReg=/^[a-zA-Z0-9_-]+@([a-zA-Z0-9]+\.)+(com|cn|net|org)$/;
 
@@ -141,10 +168,11 @@
             message: '邮箱格式有误',
             type: 'error'
           });
+          this.$refs.email.focus();
           return false;
         }
 
-        if(this.phone.length < 11){
+        if(this.phone.length !== 11){
           if(this.phone.length === 0){
             this.$message({
               showClose: true,
@@ -172,6 +200,15 @@
           this.$refs.identifyCode.focus();
           return false;
         }
+        if(this.identifyCode.length !== 4){
+          this.$message({
+            showClose: true,
+            message: '验证码长度错误',
+            type: 'error'
+          });
+          this.$refs.identifyCode.focus();
+          return false;
+        }
 
         return true;
 

+ 6 - 0
server/controller/user.js

@@ -45,6 +45,12 @@ class UserController {
               const token = jwt.sign(data, secret.sign);
 
               //ctx.redirect(redirect_uri + "?id_token=" + token);
+              ctx.cookies.set('redirect_uri', '', {
+                maxAge:0
+              });
+              ctx.cookies.set('client_id', '', {
+                maxAge:0
+              });
 
               ctx.body = Response.success({token: token, name: user.name, path:redirect_uri});
             }