1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- 'use strict';
- var auth = angular.module('authApp', ['ngCookies','authctrl']);
- angular.module('authctrl', ['authsvc']);
- angular.module('authsvc', []);
-
- angular.module('authctrl').controller('authcontroller', function($scope, $cookieStore, identitysvc){
- $scope.identity = function(nickname){
- identitysvc.identity(nickname).then(function(response){
- var valueJson = JSON.stringify(response);
- var valueObject = JSON.parse(valueJson);
- // console.log(valueObject);
- var status = valueObject.status;
- if (status == "200") {
- var user=valueObject.data.user;
- if(angular.isUndefined(user.id)){
- }else{
- var id=user.id;
- window.sessionStorage.setItem("userId",id);
- window.sessionStorage.setItem("userNameToken",user.name);
- $cookieStore.put("userObm", user);
- $cookieStore.put("menuObm", valueObject.data.menu);
- $cookieStore.put("session", valueObject.data.sessionId);
- $scope.username = user.name;
- }
- }
- });
- }
- });
- auth.value('server',{
- host:'192.168.3.233',
- getUrl: function(data){
- return 'http://' + this.host + ':9002/services/auth/sso/';
- }
- });
- angular.module('authsvc')
- .factory('identitysvc', function ($rootScope, $http, $q, $timeout, server) {
- return {
- identity: function(nickname){
- server.getUrl('user')+nickname;
- return $http.get(server.getUrl('user')+nickname);
- }
- };
- });
|