Merge remote-tracking branch 'origin/fixedSignupErrors' into features/missing

# Conflicts:
#	public/modules/users/config/users.client.routes.js
#	public/modules/users/controllers/settings.client.controller.js
#	public/modules/users/views/settings/change-password.client.view.html
This commit is contained in:
wodka 2019-07-11 23:36:34 +02:00
commit b83b431c95
4 changed files with 56 additions and 41 deletions

View File

@ -4,25 +4,26 @@
angular.module('users').config(['$stateProvider',
function($stateProvider) {
var checkCurrentUser = function($q, $state, User, Auth) {
var deferred = $q.defer();
var checkLoggedin = function($q, $timeout, $state, User, Auth) {
if (Auth.currentUser && Auth.currentUser.email) {
deferred.resolve(Auth.currentUser);
} else {
User.getCurrent().then(
function(user) {
Auth.login();
deferred.resolve(user);
return;
}
else {
return User.getCurrent().then(
function(user) {
Auth.login(user);
return;
},
function() {
Auth.logout();
deferred.reject();
$timeout(deferred.reject());
$state.go('signin', {reload: true});
return;
});
}
return deferred.promise;
};
var checkSignupDisabled = function($window, $timeout, $q) {

View File

@ -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;
});
};
*/
}
]);

View File

@ -1,47 +1,32 @@
'use strict';
angular.module('users').controller('SettingsController', ['$scope', '$rootScope', '$http', '$state', 'Users', 'Auth', 'currentUser', 'USERS_URL', '$translate',
function($scope, $rootScope, $http, $state, Users, Auth, currentUser, USERS_URL, $translate) {
angular.module('users').controller('SettingsController', ['$scope', '$rootScope', '$http', '$state', 'Users', 'Auth',
function($scope, $rootScope, $http, $state, Users, Auth) {
$scope.user = currentUser;
$scope.user = Auth.currentUser;
$scope.cancel = function(){
$scope.user = currentUser;
};
$scope.user = Auth.currentUser;
}
// Update a user profile
$scope.updateUserProfile = function(isValid) {
if (isValid && $scope.user) {
if (isValid) {
$scope.success = $scope.error = null;
var user = new Users($scope.user);
$http.put(USERS_URL, $scope.user).then(function(response){
user.$update(function(response) {
$scope.success = true;
$scope.error = null;
$scope.user = response.data;
$translate.use($scope.user.language);
Auth.update($scope.user);
}, function(error) {
$scope.user = response;
$scope.$apply();
}, function(response) {
$scope.success = null;
$scope.error = 'Could not update your profile due to an error with the server. Sorry about this!'
$scope.error = response.data.message;
});
} else {
$scope.submitted = true;
}
};
// Change user password
$scope.changeUserPassword = function() {
$scope.success = $scope.error = null;
$http.post('/users/password', $scope.passwordDetails).then(function(response) {
// If successful show success message and clear form
$scope.success = true;
$scope.error = null;
$scope.passwordDetails = null;
}, function(errResponse) {
$scope.success = null;
$scope.error = errResponse.message;
});
};
}
]);

View File

@ -1,6 +1,6 @@
<header data-ng-include="'/static/modules/core/views/header.client.view.html'"></header>
<section class="row">
<section class="row" data-ng-controller="ChangePasswordController">
<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">
<form data-ng-submit="changeUserPassword()" class="signin form-horizontal" autocomplete="off">