Kaynağa Gözat

单点登录

seimin 3 yıl önce
ebeveyn
işleme
4f838fa038

+ 43 - 10
assets/js/controllers/loginCtrl.js

@@ -1,7 +1,9 @@
1
-app.controller('LoginCtrl', ['$rootScope', '$scope', '$state', '$translate', '$localStorage', '$cookieStore', '$auth', '$window', '$document', '$timeout', '$filter', '$http', 'cfpLoadingBar', 'Restangular', 'api_login', 'api_is_category', 'SweetAlert','api_msg',
1
+app.controller('LoginCtrl', ['$rootScope', '$scope', '$state', '$translate', '$localStorage', '$cookieStore', '$auth', '$window', '$document', '$timeout', '$filter', '$http', 'cfpLoadingBar', 'Restangular', 'api_login', 'api_is_category', 'SweetAlert', 'api_msg',
2
-    function ($rootScope, $scope, $state, $translate, $localStorage, $cookieStore, $auth, $window, $document, $timeout, $filter, $http, cfpLoadingBar, Restangular, api_login, api_is_category, SweetAlert,api_msg) {
2
+    function ($rootScope, $scope, $state, $translate, $localStorage, $cookieStore, $auth, $window, $document, $timeout, $filter, $http, cfpLoadingBar, Restangular, api_login, api_is_category, SweetAlert, api_msg) {
3
         $rootScope.app.layout.isNavbarFixed = false;
3
         $rootScope.app.layout.isNavbarFixed = false;
4
         $rootScope.app.layout.isSidebarFixed = false;
4
         $rootScope.app.layout.isSidebarFixed = false;
5
+        // 是否单点登录
6
+        $scope.isSSo = location.search.length > 0;
5
         //初始化,获取版本类别,处理人/处理科室-seimin
7
         //初始化,获取版本类别,处理人/处理科室-seimin
6
         $scope.isCategoryHandle = function () {
8
         $scope.isCategoryHandle = function () {
7
             api_is_category.isCategory({ "idx": 0, "sum": 1000, "systemConfiguration": { "keyconfig": "repairMain" } })
9
             api_is_category.isCategory({ "idx": 0, "sum": 1000, "systemConfiguration": { "keyconfig": "repairMain" } })
@@ -66,7 +68,11 @@ app.controller('LoginCtrl', ['$rootScope', '$scope', '$state', '$translate', '$l
66
         $scope.licensePassSub = function () {
68
         $scope.licensePassSub = function () {
67
             if ($scope.licenseIsAdmin) {
69
             if ($scope.licenseIsAdmin) {
68
                 $scope.licensePassShow = false;
70
                 $scope.licensePassShow = false;
69
-                $state.go('login.license');
71
+                if ($scope.isSSo) {
72
+                    location.href = 'http://' + document.domain + '/#/login/license';
73
+                } else {
74
+                    $state.go('login.license');
75
+                }
70
             } else {
76
             } else {
71
                 $scope.licensePassShow = false;
77
                 $scope.licensePassShow = false;
72
             }
78
             }
@@ -74,19 +80,31 @@ app.controller('LoginCtrl', ['$rootScope', '$scope', '$state', '$translate', '$l
74
         $scope.licenseSoonShowSub = function () {
80
         $scope.licenseSoonShowSub = function () {
75
             $scope.licenseSoonShow = false;
81
             $scope.licenseSoonShow = false;
76
             $rootScope.getpending();
82
             $rootScope.getpending();
77
-            $state.go('app.dashboard');
83
+            if ($scope.isSSo) {
84
+                location.href = 'http://' + document.domain + '/#/app/dashboard';
85
+            } else {
86
+                $state.go('app.dashboard');
87
+            }
78
         }
88
         }
79
         $scope.licenseTrialSub = function () {
89
         $scope.licenseTrialSub = function () {
80
             $scope.licenseTrialShow = false;
90
             $scope.licenseTrialShow = false;
81
             $rootScope.getpending();
91
             $rootScope.getpending();
82
-            $state.go('app.dashboard');
92
+            if ($scope.isSSo) {
93
+                location.href = 'http://' + document.domain + '/#/app/dashboard';
94
+            } else {
95
+                $state.go('app.dashboard');
96
+            }
83
         }
97
         }
84
         $scope.licenseTrialActivation = function () {
98
         $scope.licenseTrialActivation = function () {
85
-            $state.go('login.license');
99
+            if ($scope.isSSo) {
100
+                location.href = 'http://' + document.domain + '/#/login/license';
101
+            } else {
102
+                $state.go('login.license');
103
+            }
86
         }
104
         }
87
         $scope.licenseIsAdmin = "";
105
         $scope.licenseIsAdmin = "";
88
 
106
 
89
-            // 未读消息数量
107
+        // 未读消息数量
90
         // $scope.noReadData=0
108
         // $scope.noReadData=0
91
         // $rootScope.getMsgNum=function(id){
109
         // $rootScope.getMsgNum=function(id){
92
         //     api_msg.msgDataList({idx: 0, sum: 1, messageStation: {readStatus: 0, userId: id}}).then(function(data) {
110
         //     api_msg.msgDataList({idx: 0, sum: 1, messageStation: {readStatus: 0, userId: id}}).then(function(data) {
@@ -98,12 +116,20 @@ app.controller('LoginCtrl', ['$rootScope', '$scope', '$state', '$translate', '$l
98
         //     return $rootScope.noReadData
116
         //     return $rootScope.noReadData
99
         //     })
117
         //     })
100
         // }
118
         // }
101
-
102
         //登录
119
         //登录
103
         $scope.handleLoginClick = function (e) {
120
         $scope.handleLoginClick = function (e) {
104
             // api_login.getLicense({}).then(function(res){
121
             // api_login.getLicense({}).then(function(res){
105
             // $auth.submitLogin($scope.loginForm)
122
             // $auth.submitLogin($scope.loginForm)
106
-            api_login.login($scope.loginForm)
123
+            // var ssoStr = location.search.replace('?', '').split('&')[0].split('=')[1];
124
+            var ssoStr = '';
125
+            var ssoJson;
126
+            if ($scope.isSSo) {
127
+                ssoStr = location.search.replace('?', '').split('&')[0].split('=')[1];
128
+                ssoStr = Base64.decode(decodeURIComponent(ssoStr));
129
+                ssoJson = JSON.parse(ssoStr);
130
+            }
131
+            var postData = $scope.isSSo ? { username: ssoJson.a, password: ssoJson.u, t: false } : $scope.loginForm;
132
+            api_login.login(postData)
107
                 .then(function (resp) {
133
                 .then(function (resp) {
108
                     console.log(resp);
134
                     console.log(resp);
109
                     if (resp.state == "10000") {//license失效
135
                     if (resp.state == "10000") {//license失效
@@ -456,7 +482,11 @@ app.controller('LoginCtrl', ['$rootScope', '$scope', '$state', '$translate', '$l
456
                                         if (resp.data && resp.data.user && resp.data.user.id) {
482
                                         if (resp.data && resp.data.user && resp.data.user.id) {
457
                                             // console.log(resp.error);
483
                                             // console.log(resp.error);
458
                                             $rootScope.getpending();
484
                                             $rootScope.getpending();
459
-                                            $state.go('app.dashboard');
485
+                                            if ($scope.isSSo) {
486
+                                                location.href = 'http://' + document.domain + '/#/app/dashboard';
487
+                                            } else {
488
+                                                $state.go('app.dashboard');
489
+                                            }
460
                                             $rootScope.app.isLoginFixed = false;
490
                                             $rootScope.app.isLoginFixed = false;
461
                                             // console.log(resp);
491
                                             // console.log(resp);
462
                                             // api_wechatfile.getDictionary({ "type": "list", "key": "hjzx_cornet" }).then(function(data) {
492
                                             // api_wechatfile.getDictionary({ "type": "list", "key": "hjzx_cornet" }).then(function(data) {
@@ -487,6 +517,9 @@ app.controller('LoginCtrl', ['$rootScope', '$scope', '$state', '$translate', '$l
487
                 });
517
                 });
488
             // })        
518
             // })        
489
         };
519
         };
520
+        if ($scope.isSSo) {
521
+            $scope.handleLoginClick();
522
+        }
490
         $scope.handleloginEnter = function (e) {
523
         $scope.handleloginEnter = function (e) {
491
             if (e.keyCode == 13) {
524
             if (e.keyCode == 13) {
492
                 $scope.handleLoginClick();
525
                 $scope.handleLoginClick();

Dosya farkı çok büyük olduğundan ihmal edildi
+ 8 - 0
assets/js/script/base64.min.js


+ 1 - 1
assets/views/login_login.html

@@ -85,7 +85,7 @@
85
 </style>
85
 </style>
86
 <div class="demo-1" ng-controller="LoginCtrl">
86
 <div class="demo-1" ng-controller="LoginCtrl">
87
 
87
 
88
-    <div class="container" ng-if="!app.isChrome">
88
+    <div class="container" ng-if="!app.isChrome&&!isSSo">
89
 
89
 
90
         <header class="codrops-header">
90
         <header class="codrops-header">
91
             <!--<img src="assets/images/HBDXLG.png" style="width:300px"/>-->
91
             <!--<img src="assets/images/HBDXLG.png" style="width:300px"/>-->

+ 2 - 0
index.html

@@ -52,6 +52,8 @@
52
     <!--<script src="../bower_components/jquery-ui/jquery-ui.min.js"></script>-->
52
     <!--<script src="../bower_components/jquery-ui/jquery-ui.min.js"></script>-->
53
     <!-- md5 -->
53
     <!-- md5 -->
54
     <script src="./assets/js/script/md5.min.js"></script>
54
     <script src="./assets/js/script/md5.min.js"></script>
55
+    <!-- base64 -->
56
+    <script src="./assets/js/script/base64.min.js"></script>
55
     <!-- Fastclick -->
57
     <!-- Fastclick -->
56
     <script src="../bower_components/fastclick/lib/fastclick.js"></script>
58
     <script src="../bower_components/fastclick/lib/fastclick.js"></script>
57
     <!-- interact -->
59
     <!-- interact -->