allow users to permanently delete their account

This commit is contained in:
Athou
2013-05-08 11:15:50 +02:00
parent e68b38139e
commit ef618c1e13
6 changed files with 68 additions and 12 deletions

View File

@@ -809,8 +809,8 @@ function($scope, $location, SettingsService, AnalyticsService) {
};
}]);
module.controller('ProfileCtrl', ['$scope', '$location', 'ProfileService', 'AnalyticsService',
function($scope, $location, ProfileService, AnalyticsService) {
module.controller('ProfileCtrl', ['$scope', '$location', '$dialog', 'ProfileService', 'AnalyticsService',
function($scope, $location, $dialog, ProfileService, AnalyticsService) {
AnalyticsService.track();
@@ -832,7 +832,25 @@ function($scope, $location, ProfileService, AnalyticsService) {
ProfileService.save(o, function() {
$location.path('/');
});
};
$scope.deleteAccount = function() {
var title = 'Delete account';
var msg = 'Delete your acount? There\'s no turning back!';
var btns = [ {
result : 'cancel',
label : 'Cancel'
}, {
result : 'ok',
label : 'OK',
cssClass : 'btn-primary'
} ];
$dialog.messageBox(title, msg, btns).open().then(function(result) {
if (result == 'ok') {
ProfileService.deleteAccount();
window.location.href = 'logout';
}
});
};
}]);

View File

@@ -14,7 +14,9 @@ module.service('AnalyticsService', [ '$state', function($state) {
module.factory('ProfileService', ['$resource', function($resource) {
return $resource('rest/user/profile/');
var res = $resource('rest/user/profile/');
res.deleteAccount = $resource('rest/user/profile/deleteAccount').save;
return res;
}]);
module.factory('SettingsService', ['$resource', function($resource) {

View File

@@ -50,6 +50,7 @@
<div class="form-actions">
<button type="submit" class="btn btn-primary">Save</button>
<button type="button" class="btn" ng-click="cancel()">Cancel</button>
<button type="button" class="btn btn-danger" ng-click="deleteAccount()">Delete account</button>
</div>
</form>
</div>