(function ($ang) { 'use strict'; $ang.module('ylmis').controller("ssoCtrl", ['$scope', '$rootScope', '$state', '$http', '$loading', '$alert', '$interval', '$window', 'AuthUser', '$location', function ($scope, $rootScope, $state, $http, $loading, $alert, $interval, $window, AuthUser, $location) { $scope.errorMsg = ''; var token = $location.search().loginToken.replace(/%2B/g,'+'); var tm = $location.search().tm; var path = $location.search().re; if (token && token != "" && tm && tm != "") { $loading.show(); $http.post('/api/systemsetting/Account/SSOGetToken', { token: token, tm: tm }).then(function (req) { $loading.hide(); if (req.data.IsSuccess) { AuthUser.setUser(req.data.Data); $rootScope.refreshTokenInterval = $interval(function () { $http({ method: 'post', url: '../../api/systemsetting/Account/RefreshToken', data: {} }).then(function (req) { if (req.data.IsSuccess) { $window.localStorage["token"] = req.data.Data.Token; } else { $alert({ title: '错误', content: req.data.Data.Message + ",请重新登录", placement: 'centre', type: 'danger', show: true, duration: 3 }).then(function () { $window.location.href = "/app/main/index.html#!/login"; }) } }); }, 60000); if (path && path != "") { $location.url(path); } else { $state.go("homeTabs"); } } else { $scope.errorMsg = req.data.Message; $alert({ title: '错误', content: $scope.errorMsg, placement: 'centre', type: 'danger', show: true, duration: 3, onHide: function () { $window.location.href = "/app/main/index.html#!/login"; } }); } }, function (reason) { $loading.hide(); }); } }]); })(angular, this, CryptoJS);