mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-01-15 11:52:23 +01:00
Changed some bad comments referencing the Articles module in other modules.
Typo fixed in xxx.client.modules.js files ("Application" => "Applicaion")
Full stop character removed at the end of line comments
60 lines
1.8 KiB
JavaScript
60 lines
1.8 KiB
JavaScript
'use strict';
|
|
|
|
angular.module('users').controller('PasswordController', ['$scope', '$stateParams', '$http', '$location', 'Authentication', 'PasswordValidator',
|
|
function ($scope, $stateParams, $http, $location, Authentication, PasswordValidator) {
|
|
$scope.authentication = Authentication;
|
|
$scope.popoverMsg = PasswordValidator.getPopoverMsg();
|
|
|
|
// If user is signed in then redirect back home
|
|
if ($scope.authentication.user) {
|
|
$location.path('/');
|
|
}
|
|
|
|
// Submit forgotten password account id
|
|
$scope.askForPasswordReset = function (isValid) {
|
|
$scope.success = $scope.error = null;
|
|
|
|
if (!isValid) {
|
|
$scope.$broadcast('show-errors-check-validity', 'forgotPasswordForm');
|
|
|
|
return false;
|
|
}
|
|
|
|
$http.post('/api/auth/forgot', $scope.credentials).success(function (response) {
|
|
// Show user success message and clear form
|
|
$scope.credentials = null;
|
|
$scope.success = response.message;
|
|
|
|
}).error(function (response) {
|
|
// Show user error message and clear form
|
|
$scope.credentials = null;
|
|
$scope.error = response.message;
|
|
});
|
|
};
|
|
|
|
// Change user password
|
|
$scope.resetUserPassword = function (isValid) {
|
|
$scope.success = $scope.error = null;
|
|
|
|
if (!isValid) {
|
|
$scope.$broadcast('show-errors-check-validity', 'resetPasswordForm');
|
|
|
|
return false;
|
|
}
|
|
|
|
$http.post('/api/auth/reset/' + $stateParams.token, $scope.passwordDetails).success(function (response) {
|
|
// If successful show success message and clear form
|
|
$scope.passwordDetails = null;
|
|
|
|
// Attach user profile
|
|
Authentication.user = response;
|
|
|
|
// And redirect to the index page
|
|
$location.path('/password/reset/success');
|
|
}).error(function (response) {
|
|
$scope.error = response.message;
|
|
});
|
|
};
|
|
}
|
|
]);
|