whats in a name
whats in a name

Reputation: 87

How to invalidate a user token in loopback?

so, I'm a user manager and I want to delete an account which also means I want to invalidate that particular user access token.

I have inbuilt loopback accesstoken table which has token and userId.

Person.find({ where: { id: userId } }).then(user, function(){
   user.logout(user.id);
});

when I do this, I get the follwing error Custom inspection function on Objects via .inspect() is deprecated

I'm not sure how to logout other users.

Upvotes: 1

Views: 278

Answers (1)

Shubham
Shubham

Reputation: 170

Simply delete all the access tokens associated to that user from AccessToken table.

Below is the sample code for your reference :

            User.app.models.AccessToken.destroyAll({
                userId
            }, (err) => {
                if (err) return callback(err);
                return callback(null,true);
            });

Upvotes: 2

Related Questions