Browse Source

登录验证码

natasha 2 years ago
parent
commit
a7aea411e1
3 changed files with 54 additions and 9 deletions
  1. 37 0
      src/App.vue
  2. 13 7
      src/components/login/login.vue
  3. 4 2
      src/views/login/index.vue

+ 37 - 0
src/App.vue

@@ -29,6 +29,22 @@ export default {
       this.dir = "rtl";
     }
     this.handleUserAgentRoot()
+    window.addEventListener(
+        'click',()=>{
+            sessionStorage.setItem('lastClickTime',new Date().getTime())
+        }
+    )
+    window.addEventListener(
+        'mousewheel',()=>{
+            sessionStorage.setItem('lastClickTime',new Date().getTime())
+        }
+    )
+    window.addEventListener(
+        'mousemove',()=>{
+            sessionStorage.setItem('lastClickTime',new Date().getTime())
+        }
+    )
+
   },
   methods:{
       // 判断是否为chrome浏览器 
@@ -41,8 +57,29 @@ export default {
           sessionStorage.setItem("useragent_root_close", true);
           this.userAgentTipShow = false
       },
+    // 是否超时
+    isTimeOut(){
+        clearInterval(this.timeOut)
+        this.timeOut = setInterval(()=>{
+            let lastClickTime = sessionStorage.getItem('lastClickTime')*1
+            let nowTime = new Date().getTime()
+            let dataConfig = JSON.parse(getConfig());
+            if(nowTime - lastClickTime > 1000 * dataConfig.user_connection_timeout_duration){
+                clearInterval(this.timeOut)
+                removeSession("SysList");
+                removeToken();
+                Cookies.remove("JSESSIONID");
+                this.userShow = false;
+                this.userMessage = null;
+                sessionStorage.removeItem("useragent_root_close");
+                window.location.href = dataConfig.sys_home_url
+            }
+        })
+    }
   },
   mounted(){
+    sessionStorage.setItem('lastClickTime',new Date().getTime())
+    this.isTimeOut()
   },
 };
 </script>

+ 13 - 7
src/components/login/login.vue

@@ -110,7 +110,7 @@
             />
           </div>
         </div>
-        <!-- <div class="verificationCode-box">
+        <div class="verificationCode-box" v-if="dynamicVerificationShow">
           <input
             type="text"
             :class="'input'"
@@ -123,7 +123,7 @@
                 :class="VerificationCodeShow ? 'waitTime' : 'getVerification'">
                 {{ VerificationCodeShow ? time+'s' : $t("Key93") }}
           </div>
-        </div> -->
+        </div>
       </template>
       <!-- 验证码登录   v-show="loginType == '验证码'"
        -->
@@ -222,10 +222,11 @@ import { mapGetters } from "vuex";
 import UserAgreement from "./UserAgreement.vue"; // 用户协议
 import md5 from "js-md5";
 import { setI18nLang } from "@/utils/i18n";
+import { getConfigInfor } from "@/utils/index";
 export default {
   //import引入的组件需要注入到对象中才能使用
   components: { UserAgreement },
-  props: ["ForgetType", "changeLoginReg", "changeLoginType", "getChildSysList"],
+  props: ["ForgetType", "changeLoginReg", "changeLoginType", "getChildSysList","changeEmailTips"],
   data() {
     //这里存放数据
     return {
@@ -248,7 +249,8 @@ export default {
       verificationCodeimgID: "", // 图形验证码ID
       verificationCodeLoading: true, // 图形验证码的flag
       time: 60, //获取验证码的时间
-      emailCode: ""
+      emailCode: "",
+      dynamicVerificationShow: getConfigInfor()&&getConfigInfor().is_enable_dynamic_verification_code_for_user_login=='true' ? true : false
     };
   },
   //计算属性 类似于data概念
@@ -362,9 +364,9 @@ export default {
         password: md5(this.password).toUpperCase(),
         verification_code_image_text: this.verificationCode,
         verification_code_image_id: this.verificationCodeimgID,
-        // dynamic_verification_type:'EMAIL',
-        // phone_or_email: this.email_phone,
-        // dynamic_verification_code: this.emailCode
+        dynamic_verification_type:'EMAIL',
+        phone_or_email: this.email_phone,
+        dynamic_verification_code: this.emailCode
       };
       if (this.rememberMe) {
       } else {
@@ -386,6 +388,9 @@ export default {
             localStorage.setItem("user_name", JSON.stringify(obj));
           }
           setToken(res);
+          if(res.last_update_password_days>=res.sys_recommend_password_update_days){
+            this.changeEmailTips(res.last_update_password_days)
+          }else{
             this.$message.success(this.$t("Key442"));
             setI18nLang(this.language_type).then(() => {
                 if (
@@ -398,6 +403,7 @@ export default {
                     this.getChildSysList();
                 }
             });
+          }
         })
         .catch((err) => {
           this.isLogin = false;

+ 4 - 2
src/views/login/index.vue

@@ -32,6 +32,8 @@
               :changeLoginReg="changeLoginReg"
               :changeLoginType="changeLoginType"
               :getChildSysList="getChildSysList"
+              :changeEmailTips="changeEmailTips"
+
             />
           </div>
           <div
@@ -89,7 +91,7 @@
         <p>{{ $t("Key247") }}...</p>
       </div>
     </template>
-    <!-- <div class="emailTipsBox" v-if="emailTipShow">
+    <div class="emailTipsBox" v-if="emailTipShow">
         <div class="emailTipsBox-innder">
             <img
                 src="../../assets/login/close-forget.png"
@@ -100,7 +102,7 @@
             <b>您已{{emailTipDay}}天未修改密码,为了账户安全,请更改密码。</b>
             <a @click="changeLoginReg('Forget password')">好的</a>
         </div>
-    </div> -->
+    </div>
   </div>
 </template>