mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-01-16 12:22:26 +01:00
30 lines
804 B
JavaScript
30 lines
804 B
JavaScript
'use strict';
|
|
|
|
angular.module('users').controller('EditProfileController', ['$scope', '$http', '$location', 'Users', 'Authentication',
|
|
function ($scope, $http, $location, Users, Authentication) {
|
|
$scope.user = Authentication.user;
|
|
|
|
// Update a user profile
|
|
$scope.updateUserProfile = function (isValid) {
|
|
$scope.success = $scope.error = null;
|
|
|
|
if (!isValid) {
|
|
$scope.$broadcast('show-errors-check-validity', 'userForm');
|
|
|
|
return false;
|
|
}
|
|
|
|
var user = new Users($scope.user);
|
|
|
|
user.$update(function (response) {
|
|
$scope.$broadcast('show-errors-reset', 'userForm');
|
|
|
|
$scope.success = true;
|
|
Authentication.user = response;
|
|
}, function (response) {
|
|
$scope.error = response.data.message;
|
|
});
|
|
};
|
|
}
|
|
]);
|