103 lines
2.7 KiB
JavaScript
Executable file
103 lines
2.7 KiB
JavaScript
Executable file
'use strict';
|
|
|
|
// Setting up route
|
|
angular.module('users').config(['$stateProvider',
|
|
function($stateProvider) {
|
|
|
|
var checkLoggedin = function($q, $timeout, $location, User, Auth) {
|
|
var deferred = $q.defer();
|
|
|
|
console.log(Auth.getUserState);
|
|
|
|
if (Auth.currentUser && Auth.currentUser.email) {
|
|
$timeout(deferred.resolve);
|
|
}
|
|
else {
|
|
Auth.currentUser = User.getCurrent(function() {
|
|
Auth.login();
|
|
$timeout(deferred.resolve);
|
|
},
|
|
function() {
|
|
Auth.logout();
|
|
$timeout(deferred.reject);
|
|
$location.path('/login');
|
|
});
|
|
}
|
|
|
|
return deferred.promise;
|
|
};
|
|
|
|
// Users state routing
|
|
$stateProvider.
|
|
state('profile', {
|
|
// parent: 'restricted',
|
|
// data: {
|
|
// roles: ['user', 'admin'],
|
|
// },
|
|
resolve: {
|
|
loggedin: checkLoggedin
|
|
},
|
|
url: '/settings/profile',
|
|
templateUrl: 'modules/users/views/settings/edit-profile.client.view.html'
|
|
}).
|
|
state('password', {
|
|
// resolve: {
|
|
// checkLoggedin: Authorization.authorize
|
|
// },
|
|
// parent: 'restricted',
|
|
// data: {
|
|
// roles: ['user', 'admin'],
|
|
// },
|
|
resolve: {
|
|
loggedin: checkLoggedin
|
|
},
|
|
url: '/settings/password',
|
|
templateUrl: 'modules/users/views/settings/change-password.client.view.html'
|
|
}).
|
|
state('accounts', {
|
|
// parent: 'restricted',
|
|
// data: {
|
|
// roles: ['user', 'admin'],
|
|
// },
|
|
resolve: {
|
|
loggedin: checkLoggedin
|
|
},
|
|
url: '/settings/accounts',
|
|
templateUrl: 'modules/users/views/settings/social-accounts.client.view.html'
|
|
}).
|
|
|
|
state('signup', {
|
|
url: '/signup',
|
|
templateUrl: 'modules/users/views/authentication/signup.client.view.html'
|
|
}).
|
|
state('signup-success', {
|
|
url: '/signup-success',
|
|
templateUrl: 'modules/users/views/authentication/signup.client.view.html'
|
|
}).
|
|
state('signin', {
|
|
url: '/signin',
|
|
templateUrl: 'modules/users/views/authentication/signin.client.view.html'
|
|
}).
|
|
state('access_denied', {
|
|
url: '/access_denied',
|
|
templateUrl: 'modules/users/views/authentication/access-denied.client.view.html'
|
|
}).
|
|
|
|
state('forgot', {
|
|
url: '/password/forgot',
|
|
templateUrl: 'modules/users/views/password/forgot-password.client.view.html'
|
|
}).
|
|
state('reset-invalid', {
|
|
url: '/password/reset/invalid',
|
|
templateUrl: 'modules/users/views/password/reset-password-invalid.client.view.html'
|
|
}).
|
|
state('reset-success', {
|
|
url: '/password/reset/success',
|
|
templateUrl: 'modules/users/views/password/reset-password-success.client.view.html'
|
|
}).
|
|
state('reset', {
|
|
url: '/password/reset/:token',
|
|
templateUrl: 'modules/users/views/password/reset-password.client.view.html'
|
|
});
|
|
}
|
|
]); |