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

32 lines
802 B
JavaScript
Raw Normal View History

2016-04-14 19:50:10 +02:00
(function() {
'use strict';
angular
.module('harbor.session')
.controller('CurrentUserController', CurrentUserController)
CurrentUserController.$inject = ['CurrentUserService', 'currentUser', '$scope', '$timeout'];
2016-04-14 19:50:10 +02:00
function CurrentUserController(CurrentUserService, currentUser, $scope, $timeout) {
var vm = this;
2016-04-14 19:50:10 +02:00
CurrentUserService()
.then(getCurrentUserComplete)
.catch(getCurrentUserFailed);
function getCurrentUserComplete(response) {
console.log('Successful logged in.');
$timeout(function(){
$scope.$broadcast('currentUser', response.data);
currentUser.set(response.data);
}, 50);
2016-04-14 19:50:10 +02:00
}
function getCurrentUserFailed(e){
console.log('Have not logged in yet.');
2016-04-14 19:50:10 +02:00
}
}
})();