mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-03-26 22:00:16 +01:00
34 lines
1013 B
JavaScript
34 lines
1013 B
JavaScript
'use strict';
|
|
|
|
angular.module('mean.users').controller('SettingsController', ['$scope', '$http', '$location', 'Users', 'Authentication',
|
|
function($scope, $http, $location, Users, Authentication) {
|
|
$scope.user = Authentication.user;
|
|
|
|
//If user is not signed in then redirect back home
|
|
if (!$scope.user) $location.path('/');
|
|
|
|
$scope.updateUserProfile = function() {
|
|
$scope.success = $scope.error = null;
|
|
var user = new Users($scope.user);
|
|
|
|
user.$update(function(response) {
|
|
$scope.success = true;
|
|
Authentication.user = response;
|
|
}, function(response) {
|
|
$scope.error = response.data.message;
|
|
});
|
|
};
|
|
|
|
$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.passwordDetails = null;
|
|
}).error(function(response) {
|
|
$scope.error = response.message;
|
|
});
|
|
};
|
|
}
|
|
]); |