fixed signin redirect bug

This commit is contained in:
David Baldwynn 2017-11-02 10:33:27 -07:00
parent 65a8b2d7cc
commit 6927f9d5ac
8 changed files with 27 additions and 18 deletions

View File

@ -190,7 +190,7 @@ exports.signin = function(req, res, next) {
*/
exports.signout = function(req, res) {
if(req.cookies.hasOwnProperty('userLang')){
res.destroyCookie('userLang');
res.clearCookie('userLang');
}
req.logout();
return res.status(200).send('You have successfully logged out.');

View File

@ -664,7 +664,7 @@ ApplicationConfiguration.registerModule('core', ['users']);
// Use Application configuration module to register a new module
ApplicationConfiguration.registerModule('forms', [
'ngFileUpload', 'ui.router.tabs', 'ui.date', 'ui.sortable',
'ngFileUpload', 'ui.date', 'ui.sortable',
'angular-input-stars', 'users', 'ngclipboard'
]);//, 'colorpicker.module' @TODO reactivate this module

File diff suppressed because one or more lines are too long

View File

@ -15,10 +15,13 @@ angular.module(ApplicationConfiguration.applicationModuleName).run(['$rootScope'
$rootScope.$stateParams = $stateParams;
// add previous state property
$rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState) {
$state.previous = fromState;
$rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) {
$state.previous = {
state: fromState,
params: fromParams
}
var statesToIgnore = ['home', 'signin', 'resendVerifyEmail', 'verify', 'signup', 'signup-success', 'forgot', 'reset-invalid', 'reset', 'reset-success'];
var statesToIgnore = ['', 'home', 'signin', 'resendVerifyEmail', 'verify', 'signup', 'signup-success', 'forgot', 'reset-invalid', 'reset', 'reset-success'];
//Redirect to listForms if user is authenticated
if(statesToIgnore.indexOf(toState.name) > 0){

View File

@ -57,7 +57,10 @@ angular.module('forms').config(['$stateProvider',
});
return deferred.promise;
}
},
formId: ['$stateParams', function ($stateParams) {
return $stateParams.formId;
}]
},
controller: 'AdminFormController'
}).state('viewForm.configure', {

View File

@ -2,6 +2,6 @@
// Use Application configuration module to register a new module
ApplicationConfiguration.registerModule('forms', [
'ngFileUpload', 'ui.router.tabs', 'ui.date', 'ui.sortable',
'ngFileUpload', 'ui.date', 'ui.sortable',
'angular-input-stars', 'users', 'ngclipboard'
]);//, 'colorpicker.module' @TODO reactivate this module

View File

@ -8,6 +8,7 @@ angular.module('forms').factory('GetForms', ['$resource', 'FORM_URL',
}, {
'query' : {
method: 'GET',
url: '/forms',
isArray: true
},
'get' : {

View File

@ -8,6 +8,8 @@ angular.module('users').controller('AuthenticationController', ['$scope', '$loca
$scope.error = '';
$scope.forms = {};
var statesToIgnore = ['', 'home', 'signin', 'resendVerifyEmail', 'verify', 'signup', 'signup-success', 'forgot', 'reset-invalid', 'reset', 'reset-success'];
$scope.signin = function() {
if(!$scope.forms.signinForm.$invalid){
User.login($scope.credentials).then(
@ -15,8 +17,8 @@ angular.module('users').controller('AuthenticationController', ['$scope', '$loca
Auth.login(response);
$scope.user = $rootScope.user = Auth.ensureHasCurrentUser(User);
if($state.previous.name !== 'home' && $state.previous.name !== 'verify' && $state.previous.name !== '') {
$state.go($state.previous.name);
if(statesToIgnore.indexOf($state.previous.state.name) === -1) {
$state.go($state.previous.state.name, $state.previous.params);
} else {
$state.go('listForms');
}