Prechádzať zdrojové kódy

解决用户注册重复问题

laiguoran 5 rokov pred
rodič
commit
d59fb98612
2 zmenil súbory, kde vykonal 13 pridanie a 3 odobranie
  1. 8 2
      modules/all_models/user.js
  2. 5 1
      web/users/js/login.js

+ 8 - 2
modules/all_models/user.js

@@ -38,10 +38,16 @@ const userdList = mongoose.Schema({
 
 // 表结构
 let schema = {
-    ssoId: Number,
+    ssoId: {
+        type: Number,
+        unique: true,
+    },
     username: String,
     email: String,
-    mobile: String,
+    mobile: {
+        type: String,
+        unique: true,
+    },
     qq: {
         type: String,
         default: ''

+ 5 - 1
web/users/js/login.js

@@ -266,7 +266,7 @@ $(document).ready(function () {
 });
 
 function login(captchaObj) {
-
+    $('#login').attr('disabled', true);
     let geetest_challenge = $('input[name="geetest_challenge"]').val();
     let geetest_validate = $('input[name="geetest_validate"]').val();
     let geetest_seccode = $('input[name="geetest_seccode"]').val();
@@ -315,19 +315,23 @@ function login(captchaObj) {
                 // captchaObj.reset();
                 $('#check_ssoId').val(response.ssoId);
                 $('#phone').modal('show');
+                $('#login').removeAttr('disabled');
             } else if(response.error === 3) {
                 // captchaObj.reset();
                 $('#phonepass').modal('show');
                 $('#mobileLogin').val(response.data);
+                $('#login').removeAttr('disabled');
             } else {
                 // $('#phonepass').modal('hide');
                 let msg = response.msg !== undefined ? response.msg : '未知错误';
                 showError(msg, $("input"));
+                $('#login').removeAttr('disabled');
                 // captchaObj.reset();
             }
         },
         error: function (result) {
             showError('内部程序错误', null);
+            $('#login').removeAttr('disabled');
         }
     });
 }