colinskow / ng-superlogin

AngularJS bindings for the SuperLogin project
MIT License
15 stars 17 forks source link

Delete / Remove a user #14

Closed ichagas closed 8 years ago

ichagas commented 8 years ago

In the server side the superlogin.removeUser() worked OK. However, I want offer to users the option to delete their account directly from the App. This is why I need this implemented in NG-Superlogin

Looking on both repositories (SuperLogin and NG-Superlogin) I couldn't found a source code that make a reference to this API, any thoughts?

Thanks!

colinskow commented 8 years ago

This functionality is implemented in Superlogin-Demo. If you are using Angular the code is very simple... return $http.post('/user/destroy');

colinskow commented 8 years ago

And here is the Express endpoint to accomplish the above...

app.post('/user/destroy', superlogin.requireAuth, function(req, res, next) {
  superlogin.removeUser(req.user._id, true)
    .then(function() {
      console.log('User destroyed!');
      res.status(200).json({ok: true, success: 'User: ' + req.user._id + ' destroyed.'});
    }, function(err) {
      return next(err);
    });
});
ichagas commented 8 years ago

Thanks @colinskow! It worked like a charm!

Thank you very much on the work you have done and shared, it is truly powerful.