Browse Source

登录验证密码有效期

seimin 1 year ago
parent
commit
433ae8da2f
2 changed files with 14 additions and 6 deletions
  1. 8 2
      assets/js/controllers/loginCtrl.js
  2. 6 4
      assets/js/controllers/mainCtrl.js

+ 8 - 2
assets/js/controllers/loginCtrl.js

@@ -586,7 +586,13 @@ app.controller('LoginCtrl', ['$rootScope', '$scope', '$state', '$translate', '$l
586 586
                                         if (resp.data && resp.data.user && resp.data.user.id) {
587 587
                                             // console.log(resp.error);
588 588
                                             $rootScope.getpending();
589
-                                            $state.go('app.dashboard');
589
+                                            // 正常登录并且密码有效期已过
590
+                                            if(resp.overTime && !$scope.isSSo){
591
+                                                $rootScope.changepassword(true);
592
+                                                return;
593
+                                            }else{
594
+                                                $state.go('app.dashboard');
595
+                                            }
590 596
                                             $rootScope.app.isLoginFixed = false;
591 597
                                             // console.log(resp);
592 598
                                             // api_wechatfile.getDictionary({ "type": "list", "key": "hjzx_cornet" }).then(function(data) {
@@ -617,7 +623,7 @@ app.controller('LoginCtrl', ['$rootScope', '$scope', '$state', '$translate', '$l
617 623
                     // SweetAlert.swal("系统错误,请重试!", "登录错误", "error");
618 624
                     SweetAlert.swal("用户名或者密码验证失败,请重试!", "error");
619 625
                 });
620
-            // })        
626
+            // })
621 627
         };
622 628
         if ($scope.isSSo) {
623 629
             $scope.handleLoginClick();

+ 6 - 4
assets/js/controllers/mainCtrl.js

@@ -48,8 +48,8 @@ app.controller('AppCtrl', ['$rootScope', '$scope', '$state', '$translate', '$loc
48 48
     $rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
49 49
       console.log(event, toState, toParams, fromState, fromParams)
50 50
       // 修改密码验证
51
-      // if(toState.name != 'login.signin'){
52
-      //   $rootScope.changepassword();
51
+      // if((fromState.name != 'login.signin' || toState.name != 'login.signin') && localStorage.getItem('isSSo') === '0' && localStorage.getItem('isOverTime') === '1'){
52
+      //   $rootScope.changepassword(true);
53 53
       // }
54 54
       if ((toState.name == 'app.incident.chart' || toState.name == 'app.incident.editor') &&
55 55
         fromState.name) {
@@ -2214,8 +2214,9 @@ app.controller('AppCtrl', ['$rootScope', '$scope', '$state', '$translate', '$loc
2214 2214
       });
2215 2215
 
2216 2216
     }
2217
-    $rootScope.changepassword = function () {
2217
+    $rootScope.changepassword = function (isNoClose = false) {
2218 2218
       var modalInstance = $modal.open({
2219
+        backdrop: !isNoClose,
2219 2220
         templateUrl: 'assets/views/changepassword.html',
2220 2221
         controller: function ($scope, $modalInstance, items, Restangular, SweetAlert) {
2221 2222
           $scope.passwordnull = function (originalPwd, pwd, pwd_2) {
@@ -2234,7 +2235,7 @@ app.controller('AppCtrl', ['$rootScope', '$scope', '$state', '$translate', '$loc
2234 2235
               });
2235 2236
               return;
2236 2237
             }
2237
-            if (pwd == pwd_2 && !(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,20}$/.test(pwd))) {
2238
+            if (pwd == pwd_2 && !(/^(?=.*[a-z])(?=.*[A-Z]).{8,20}$/.test(pwd))) {
2238 2239
               SweetAlert.swal({
2239 2240
                 title: "密码长度8-20位,必须包含大写和小写!",
2240 2241
                 text: "输入错误,请重新输入!",
@@ -2255,6 +2256,7 @@ app.controller('AppCtrl', ['$rootScope', '$scope', '$state', '$translate', '$loc
2255 2256
                   type: "success",
2256 2257
                   confirmButtonColor: "#007AFF"
2257 2258
                 });
2259
+                isNoClose && $state.go('app.dashboard');
2258 2260
               } else {
2259 2261
                 SweetAlert.swal({
2260 2262
                   title: "修改失败!",