فهرست منبع

web端单点登录

pengjing 7 ماه پیش
والد
کامیت
681b9ac711

+ 5 - 2
src/main/java/com/ghsc/partybuild/controller/AppController.java

@@ -62,7 +62,7 @@ public class AppController {
     public String app(HttpServletRequest request, HttpServletResponse response, String ticket) {
         if (appConfig.isPortalLogin && !stringUtils.IsNullOrEmpty(ticket)) {
             if (portalLogin(request, response, ticket)) {
-                return "redirect:/app/main/index.html/#/portalLogin";
+                return "redirect:/app/main/index.html#!/portalLogin";
             }
         }
 
@@ -74,7 +74,7 @@ public class AppController {
     public String web(HttpServletRequest request, HttpServletResponse response, String ticket) {
         if (appConfig.isPortalLogin && !stringUtils.IsNullOrEmpty(ticket)) {
             if (portalLogin(request, response, ticket)) {
-                return "redirect:/app/main/index.html/#/portalLogin";
+                return "redirect:/app/main/index.html#!/portalLogin";
             }
         }
 
@@ -92,6 +92,7 @@ public class AppController {
 
     /**
      * 单点登录,验证ticket
+     *
      * @param request
      * @param response
      * @param ticket
@@ -113,6 +114,8 @@ public class AppController {
 
             String userId = reqData.substring(i + "<cas:user>".length(), j);
 
+            /*String userId = "測試賬號";*/
+
             logger.info("PortalLogin,userId:" + userId);
 
             CfUsers User = userService.getUserByKey(userId);

+ 18 - 4
src/main/resources/static/app/main/default.js

@@ -1,9 +1,7 @@
 (function ($ang, win) {
     'use strict';
     $ang.module('gtPartyApp').controller("defaultCtrl", ['$scope', '$state', '$http', '$loading', '$alert', '$desData', '$modal', 'AuthUser', function ($scope, $state, $http, $loading, $alert, $desData, $modal, AuthUser) {
-        if (AuthUser && AuthUser.getUser().Id && AuthUser.getUser().Id != 'null') {
-            $state.go('homeTabs');
-        } else {
+        $scope.toLogin = function () {
             $http.get("../../api/oauth/getOAuthUrl", {}).then(function (res) {
                 if (res.data.success && res.data.item) {
                     window.location.href = res.data.item;
@@ -15,7 +13,7 @@
             }, () => {
                 $state.go('login');
             });
-        }
+        };
 
         $scope.showMsg = function (title, content) {
             $alert({
@@ -28,5 +26,21 @@
             });
 
         };
+
+        //判断登录情况
+        if (AuthUser && AuthUser.getUser().Id && AuthUser.getUser().Id != 'null') {
+            $http.get("../../api/user/curloginuser", {params: {appkey: "appId"}}).then(function (res) {
+                if (res.data.success && res.data.item) {
+                    $state.go('homeTabs');
+                } else {
+                    $scope.toLogin();
+                }
+            }, () => {
+                $scope.toLogin();
+            });
+        } else {
+            $scope.toLogin();
+        }
+
     }]);
 })(angular, this);

+ 4 - 25
src/main/resources/static/app/main/portalLogin.js

@@ -2,32 +2,11 @@
     'use strict';
     $ang.module('gtPartyApp').controller("portalLoginCtrl", ['$scope', '$state', '$http', '$loading', '$alert', '$desData', '$modal', 'AuthUser', function ($scope, $state, $http, $loading, $alert, $desData, $modal, AuthUser) {
         $scope.sysName = window.sysCompanyName;
-        $scope.errorMsg = '';
-        //站点ID
-        $scope.menudatas = {
-            appkey: "appId",
-            defrolekey: "DefaultRoleId",
-            getMenuUrl: '../../api/user/getmenubyuid',
-            toggle: true
-        };
-        $scope.loadCurUser = function () {
-            $http.get("../../api/user/curloginuser", {params: {appkey: $scope.menudatas.appkey}}).then(function (res) {
-                if (res.data.success) {
-                    if (res.data.item) {
-                        angular.extend(res.data.item, {dataDzzdm: res.data.extdata.dataDzzdm});
-                        angular.extend(res.data.item, {gddwdm: res.data.extdata.gddwdm});
-                        angular.extend(res.data.item, {userType: res.data.extdata.userType});
-                        angular.extend(res.data.item, {dataScope: res.data.extdata.dataScope});
-                        angular.extend(res.data.item, {dwId: res.data.extdata.dwId});
-                        angular.extend(res.data.item, {dwName: res.data.extdata.dwName});
-                        angular.extend(res.data.item, {oaUserId: res.data.extdata.oaUserId});
-                        angular.extend(res.data.item, {oaIdCard: res.data.extdata.oaIdCard});
-                        angular.extend(res.data.item, {generalPartyCode: res.data.extdata.generalPartyCode});
-                        AuthUser.setUser(res.data.item);
-                        AuthUser.clearExtData();
 
-                        $state.go('homeTabs');
-                    }
+        $scope.loadCurUser = function () {
+            $http.get("../../api/user/curloginuser", {params: {appkey: "appId"}}).then(function (res) {
+                if (res.data.success && res.data.item) {
+                    $state.go('homeTabs');
                 } else {
                     $scope.showMsg('失败','单点登录失败!');
                     $state.go('login');