2015-06-29 22:51:29 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
// Setting up route
|
2016-04-28 23:47:50 +00:00
|
|
|
angular.module('users').config(['$stateProvider',
|
2016-04-27 20:02:01 +00:00
|
|
|
function($stateProvider) {
|
2015-06-30 06:12:32 +00:00
|
|
|
|
2015-07-07 01:21:43 +00:00
|
|
|
var checkLoggedin = function($q, $timeout, $state, User, Auth) {
|
2015-06-30 19:42:02 +00:00
|
|
|
var deferred = $q.defer();
|
|
|
|
|
2016-05-10 07:25:00 +00:00
|
|
|
//console.log(Auth.ensureHasCurrentUser(User));
|
2015-06-30 19:42:02 +00:00
|
|
|
|
|
|
|
if (Auth.currentUser && Auth.currentUser.email) {
|
|
|
|
$timeout(deferred.resolve);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Auth.currentUser = User.getCurrent(function() {
|
|
|
|
Auth.login();
|
2015-07-07 01:21:43 +00:00
|
|
|
$timeout(deferred.resolve());
|
2015-06-30 19:42:02 +00:00
|
|
|
},
|
|
|
|
function() {
|
|
|
|
Auth.logout();
|
2015-07-07 01:21:43 +00:00
|
|
|
$timeout(deferred.reject());
|
2016-05-10 07:41:10 +00:00
|
|
|
$state.go('signin', {reload: true});
|
2015-06-30 19:42:02 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return deferred.promise;
|
|
|
|
};
|
|
|
|
|
2016-05-10 07:25:00 +00:00
|
|
|
var checkSignupDisabled = function($window, $timeout, $q) {
|
|
|
|
var deferred = $q.defer();
|
|
|
|
if($window.signupDisabled) {
|
|
|
|
$timeout(deferred.reject());
|
2016-05-10 17:13:20 +00:00
|
|
|
} else {
|
|
|
|
$timeout(deferred.resolve());
|
2016-05-10 07:25:00 +00:00
|
|
|
}
|
|
|
|
return deferred.promise;
|
|
|
|
};
|
|
|
|
|
2015-06-30 19:42:02 +00:00
|
|
|
// Users state routing
|
|
|
|
$stateProvider.
|
2015-06-29 22:51:29 +00:00
|
|
|
state('profile', {
|
2015-06-30 19:42:02 +00:00
|
|
|
resolve: {
|
|
|
|
loggedin: checkLoggedin
|
|
|
|
},
|
2015-06-29 22:51:29 +00:00
|
|
|
url: '/settings/profile',
|
2016-04-27 20:02:01 +00:00
|
|
|
templateUrl: 'modules/users/views/settings/edit-profile.client.view.html'
|
2015-06-29 22:51:29 +00:00
|
|
|
}).
|
|
|
|
state('password', {
|
2015-06-30 19:42:02 +00:00
|
|
|
resolve: {
|
|
|
|
loggedin: checkLoggedin
|
|
|
|
},
|
2015-06-29 22:51:29 +00:00
|
|
|
url: '/settings/password',
|
2016-04-27 20:02:01 +00:00
|
|
|
templateUrl: 'modules/users/views/settings/change-password.client.view.html'
|
2015-06-29 22:51:29 +00:00
|
|
|
}).
|
|
|
|
state('accounts', {
|
2015-06-30 19:42:02 +00:00
|
|
|
resolve: {
|
|
|
|
loggedin: checkLoggedin
|
|
|
|
},
|
2015-06-29 22:51:29 +00:00
|
|
|
url: '/settings/accounts',
|
2016-04-27 20:02:01 +00:00
|
|
|
templateUrl: 'modules/users/views/settings/social-accounts.client.view.html'
|
2015-06-29 22:51:29 +00:00
|
|
|
}).
|
|
|
|
state('signup', {
|
2016-05-10 07:25:00 +00:00
|
|
|
resolve: {
|
|
|
|
isDisabled: checkSignupDisabled
|
|
|
|
},
|
2015-06-29 22:51:29 +00:00
|
|
|
url: '/signup',
|
2016-04-27 20:02:01 +00:00
|
|
|
templateUrl: 'modules/users/views/authentication/signup.client.view.html'
|
2015-06-29 22:51:29 +00:00
|
|
|
}).
|
2015-06-30 19:42:02 +00:00
|
|
|
state('signup-success', {
|
2016-05-10 07:25:00 +00:00
|
|
|
resolve: {
|
|
|
|
isDisabled: checkSignupDisabled
|
|
|
|
},
|
2015-06-30 19:42:02 +00:00
|
|
|
url: '/signup-success',
|
2016-04-27 20:02:01 +00:00
|
|
|
templateUrl: 'modules/users/views/authentication/signup-success.client.view.html'
|
2015-06-30 19:42:02 +00:00
|
|
|
}).
|
2015-06-29 22:51:29 +00:00
|
|
|
state('signin', {
|
|
|
|
url: '/signin',
|
2016-04-27 20:02:01 +00:00
|
|
|
templateUrl: 'modules/users/views/authentication/signin.client.view.html'
|
2015-06-29 22:51:29 +00:00
|
|
|
}).
|
|
|
|
state('access_denied', {
|
|
|
|
url: '/access_denied',
|
2016-04-27 20:02:01 +00:00
|
|
|
templateUrl: 'modules/users/views/authentication/access-denied.client.view.html'
|
2015-06-29 22:51:29 +00:00
|
|
|
}).
|
2015-07-27 18:11:43 +00:00
|
|
|
state('resendVerifyEmail', {
|
|
|
|
url: '/verify',
|
2016-04-27 20:02:01 +00:00
|
|
|
templateUrl: 'modules/users/views/verify/resend-verify-email.client.view.html'
|
2015-07-27 18:11:43 +00:00
|
|
|
}).
|
|
|
|
state('verify', {
|
|
|
|
url: '/verify/:token',
|
2016-04-27 20:02:01 +00:00
|
|
|
templateUrl: 'modules/users/views/verify/verify-account.client.view.html'
|
2015-07-27 18:11:43 +00:00
|
|
|
}).
|
|
|
|
|
2015-06-29 22:51:29 +00:00
|
|
|
state('forgot', {
|
2015-11-12 23:40:44 +00:00
|
|
|
url: '/password/forgot',
|
2016-04-27 20:02:01 +00:00
|
|
|
templateUrl: 'modules/users/views/password/forgot-password.client.view.html'
|
2015-06-29 22:51:29 +00:00
|
|
|
}).
|
|
|
|
state('reset-invalid', {
|
2015-11-12 23:40:44 +00:00
|
|
|
url: '/password/reset/invalid',
|
2016-04-27 20:02:01 +00:00
|
|
|
templateUrl: 'modules/users/views/password/reset-password-invalid.client.view.html'
|
2015-06-29 22:51:29 +00:00
|
|
|
}).
|
|
|
|
state('reset-success', {
|
2015-11-12 23:40:44 +00:00
|
|
|
url: '/password/reset/success',
|
2016-04-27 20:02:01 +00:00
|
|
|
templateUrl: 'modules/users/views/password/reset-password-success.client.view.html'
|
2015-06-29 22:51:29 +00:00
|
|
|
}).
|
|
|
|
state('reset', {
|
2015-11-12 23:40:44 +00:00
|
|
|
url: '/password/reset/:token',
|
2016-04-27 20:02:01 +00:00
|
|
|
templateUrl: 'modules/users/views/password/reset-password.client.view.html'
|
2015-06-29 22:51:29 +00:00
|
|
|
});
|
|
|
|
}
|
2016-05-10 07:25:00 +00:00
|
|
|
]);
|