diff --git a/app/models/user.server.model.js b/app/models/user.server.model.js index 79992a82b9..2116aa635f 100755 --- a/app/models/user.server.model.js +++ b/app/models/user.server.model.js @@ -152,6 +152,10 @@ var UserSchema = new Schema({ }], default: ['gravatar'] }, + newsletter: { + type: Boolean, + default: false + }, /* For reset password */ resetPasswordToken: { type: String diff --git a/public/modules/users/controllers/settings.client.controller.js b/public/modules/users/controllers/settings.client.controller.js index 2d7dbcd376..9da60ed026 100644 --- a/public/modules/users/controllers/settings.client.controller.js +++ b/public/modules/users/controllers/settings.client.controller.js @@ -1,27 +1,39 @@ 'use strict'; -angular.module('users').controller('SettingsController', ['$scope', '$http', '$location', 'Users', - function($scope, $http, $location, Users) { +angular.module('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('/'); + // Change user email subscriptions + $scope.updateUserSubscriptions = function() { + $scope.subscriptionsSuccess = $scope.subscriptionsError = null; + var user = new Users($scope.user); + + user.$update(function(response) { + $scope.subscriptionsSuccess = 'Subscriptions updated.'; + Authentication.user = response; + }, function(response) { + $scope.subscriptionsError = response.data.message; + }); + }; // Change user password $scope.changeUserPassword = function() { - $scope.success = $scope.error = null; + $scope.passwordSuccess = $scope.passwordError = null; $http.post('/users/password', $scope.passwordDetails).success(function(response) { // If successful show success message and clear form - $scope.success = true; + $scope.passwordSuccess = true; $scope.passwordDetails = null; }).error(function(response) { - $scope.error = response.message; + $scope.passwordError = response.message; }); }; - - // Remove user permanently $scope.removalConfirm = false; $scope.removeUser = function() { diff --git a/public/modules/users/views/authentication/signup.client.view.html b/public/modules/users/views/authentication/signup.client.view.html index 144ced9756..c40ecb8ca7 100644 --- a/public/modules/users/views/authentication/signup.client.view.html +++ b/public/modules/users/views/authentication/signup.client.view.html @@ -57,10 +57,18 @@