fixed reloading bug for settings pages
This commit is contained in:
parent
3b9f01f92a
commit
eaef327b37
@ -5,25 +5,24 @@ angular.module('users').config(['$stateProvider',
|
|||||||
function($stateProvider) {
|
function($stateProvider) {
|
||||||
|
|
||||||
var checkLoggedin = function($q, $timeout, $state, User, Auth) {
|
var checkLoggedin = function($q, $timeout, $state, User, Auth) {
|
||||||
var deferred = $q.defer();
|
|
||||||
|
|
||||||
if (Auth.currentUser && Auth.currentUser.email) {
|
if (Auth.currentUser && Auth.currentUser.email) {
|
||||||
$timeout(deferred.resolve);
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Auth.currentUser = User.getCurrent(
|
return User.getCurrent().then(
|
||||||
function() {
|
function(user) {
|
||||||
Auth.login();
|
Auth.login(user);
|
||||||
$timeout(deferred.resolve());
|
return;
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
Auth.logout();
|
Auth.logout();
|
||||||
$timeout(deferred.reject());
|
$state.go('signin', {reload: true});
|
||||||
$state.go('signin', {reload: true});
|
return;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return deferred.promise;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var checkSignupDisabled = function($window, $timeout, $q) {
|
var checkSignupDisabled = function($window, $timeout, $q) {
|
||||||
|
|||||||
@ -0,0 +1,29 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
angular.module('users').controller('ChangePasswordController', ['$scope', '$rootScope', '$http', '$state', 'Users', 'Auth',
|
||||||
|
function($scope, $rootScope, $http, $state, Users, Auth) {
|
||||||
|
|
||||||
|
$scope.user = Auth.currentUser;
|
||||||
|
console.log($scope.user)
|
||||||
|
|
||||||
|
$scope.cancel = function(){
|
||||||
|
$scope.user = Auth.currentUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Change user password
|
||||||
|
$scope.changeUserPassword = function() {
|
||||||
|
$scope.success = $scope.error = null;
|
||||||
|
|
||||||
|
$http.post('/users/password', $scope.passwordDetails).success(function(response) {
|
||||||
|
// If successful show success message and clear form
|
||||||
|
$scope.success = true;
|
||||||
|
$scope.error = null;
|
||||||
|
$scope.passwordDetails = null;
|
||||||
|
}).error(function(response) {
|
||||||
|
$scope.success = null;
|
||||||
|
$scope.error = response.message;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
]);
|
||||||
@ -5,41 +5,9 @@ angular.module('users').controller('SettingsController', ['$scope', '$rootScope'
|
|||||||
|
|
||||||
$scope.user = Auth.currentUser;
|
$scope.user = Auth.currentUser;
|
||||||
|
|
||||||
// Check if there are additional accounts
|
|
||||||
$scope.hasConnectedAdditionalSocialAccounts = function(provider) {
|
|
||||||
for (var i in $scope.user.additionalProvidersData) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.cancel = function(){
|
$scope.cancel = function(){
|
||||||
$scope.user = Auth.currentUser;
|
$scope.user = Auth.currentUser;
|
||||||
};
|
}
|
||||||
|
|
||||||
// Check if provider is already in use with current user
|
|
||||||
$scope.isConnectedSocialAccount = function(provider) {
|
|
||||||
return $scope.user.provider === provider || ($scope.user.additionalProvidersData && $scope.user.additionalProvidersData[provider]);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove a user social account
|
|
||||||
$scope.removeUserSocialAccount = function(provider) {
|
|
||||||
$scope.success = $scope.error = null;
|
|
||||||
|
|
||||||
$http.delete('/users/accounts', {
|
|
||||||
params: {
|
|
||||||
provider: provider
|
|
||||||
}
|
|
||||||
}).success(function(response) {
|
|
||||||
// If successful show success message and clear form
|
|
||||||
$scope.success = true;
|
|
||||||
$scope.error = null;
|
|
||||||
$scope.user = response;
|
|
||||||
}).error(function(response) {
|
|
||||||
$scope.success = null;
|
|
||||||
$scope.error = response.message;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Update a user profile
|
// Update a user profile
|
||||||
$scope.updateUserProfile = function(isValid) {
|
$scope.updateUserProfile = function(isValid) {
|
||||||
@ -51,6 +19,7 @@ angular.module('users').controller('SettingsController', ['$scope', '$rootScope'
|
|||||||
$scope.success = true;
|
$scope.success = true;
|
||||||
$scope.error = null;
|
$scope.error = null;
|
||||||
$scope.user = response;
|
$scope.user = response;
|
||||||
|
$scope.$apply();
|
||||||
}, function(response) {
|
}, function(response) {
|
||||||
$scope.success = null;
|
$scope.success = null;
|
||||||
$scope.error = response.data.message;
|
$scope.error = response.data.message;
|
||||||
@ -59,21 +28,5 @@ angular.module('users').controller('SettingsController', ['$scope', '$rootScope'
|
|||||||
$scope.submitted = true;
|
$scope.submitted = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Change user password
|
|
||||||
$scope.changeUserPassword = function() {
|
|
||||||
$scope.success = $scope.error = null;
|
|
||||||
|
|
||||||
$http.post('/users/password', $scope.passwordDetails).success(function(response) {
|
|
||||||
// If successful show success message and clear form
|
|
||||||
$scope.success = true;
|
|
||||||
$scope.error = null;
|
|
||||||
$scope.passwordDetails = null;
|
|
||||||
}).error(function(response) {
|
|
||||||
$scope.success = null;
|
|
||||||
$scope.error = response.message;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<header data-ng-include="'/static/modules/core/views/header.client.view.html'"></header>
|
<header data-ng-include="'/static/modules/core/views/header.client.view.html'"></header>
|
||||||
|
|
||||||
<section class="row" data-ng-controller="SettingsController">
|
<section class="row" data-ng-controller="ChangePasswordController">
|
||||||
<h3 class="col-md-12 text-center">{{ 'CHANGE_PASSWORD' | translate }}</h3>
|
<h3 class="col-md-12 text-center">{{ 'CHANGE_PASSWORD' | translate }}</h3>
|
||||||
<div class="col-xs-offset-2 col-xs-8 col-md-offset-3 col-md-6">
|
<div class="col-xs-offset-2 col-xs-8 col-md-offset-3 col-md-6">
|
||||||
<form data-ng-submit="changeUserPassword()" class="signin form-horizontal" autocomplete="off">
|
<form data-ng-submit="changeUserPassword()" class="signin form-horizontal" autocomplete="off">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user