I'm building an App that requires authentication and I need to check if the user is authenticated when changing routes before instantiating the route Controller, so I need a function to retrieve the logged user from the server with $http that I need to call in the resolve property of the 'when' and then pass the retrieved user to the controller. How can I declare the function?
This is my app.js
angular.module('MasterToolsApp', ['ui.bootstrap', 'ngRoute', 'ngSanitize', 'ngResource', 'ngAnimate', 'dialogs.main', 'toasty']);
angular.module('MasterToolsApp')
.config(['$routeProvider', function($routeProvider) {
$routeProvider
.when('/', {
redirectTo: '/login'
})
.when('/login', {
templateUrl : 'dist/templates/login.html',
controller : 'LoginController',
resolve : ?
})
.when('/home', {
templateUrl : 'dist/templates/home.html',
controller : 'HomeController',
resolve : ?
})
.when('/entries', {
templateUrl : 'dist/templates/entries.html',
controller : 'EntriesController',
resolve : ?
})
.otherwise({ redirectTo: '/login' });
}]);