harbor/static/resources/js/session/session.current-user.js

33 lines
846 B
JavaScript
Raw Normal View History

2016-04-14 19:50:10 +02:00
(function() {
'use strict';
angular
.module('harbor.session')
.controller('CurrentUserController', CurrentUserController);
2016-06-25 21:12:17 +02:00
CurrentUserController.$inject = ['$scope', 'CurrentUserService', 'currentUser', '$window', '$document'];
2016-04-14 19:50:10 +02:00
2016-06-25 21:12:17 +02:00
function CurrentUserController($scope, CurrentUserService, currentUser, $window, $document) {
var vm = this;
2016-06-25 21:12:17 +02:00
CurrentUserService()
.then(getCurrentUserComplete)
.catch(getCurrentUserFailed);
function getCurrentUserComplete(response) {
if(angular.isDefined(response)) {
currentUser.set(response.data);
if(location.pathname === '/') {
$window.location.href = '/dashboard';
}
}
2016-04-14 19:50:10 +02:00
}
function getCurrentUserFailed(e){
console.log('No session of current user.');
}
2016-04-14 19:50:10 +02:00
}
2016-04-14 19:50:10 +02:00
})();