Files
meanTorrent/modules/users/client/controllers/settings/edit-profile.client.controller.js
Marek Grzybek d14d5130af feat(config): Deprecate JSHint in favor of ESLint
Add basic ESLint setup extending well-known Airbnb code style.

Fixes #1072, #1097
2016-03-15 19:11:12 +01:00

39 lines
954 B
JavaScript

(function () {
'use strict';
angular
.module('users')
.controller('EditProfileController', EditProfileController);
EditProfileController.$inject = ['$scope', '$http', '$location', 'Users', 'Authentication'];
function EditProfileController($scope, $http, $location, Users, Authentication) {
var vm = this;
vm.user = Authentication.user;
vm.updateUserProfile = updateUserProfile;
// Update a user profile
function updateUserProfile(isValid) {
vm.success = vm.error = null;
if (!isValid) {
$scope.$broadcast('show-errors-check-validity', 'vm.userForm');
return false;
}
var user = new Users(vm.user);
user.$update(function (response) {
$scope.$broadcast('show-errors-reset', 'vm.userForm');
vm.success = true;
Authentication.user = response;
}, function (response) {
vm.error = response.data.message;
});
}
}
}());