Is it possible to get access token immediately after signing up a user in loopback without having to log in the user? If so how do you go about that? Am using loopback 3
getting access token after signing up in loopback
343 Views Asked by Felix Olondea At
2
There are 2 best solutions below
0
On
I would add an after remote hook to the users/create remote method, so after it's successfully called you can call User.login() (to get the access token) with the password that you probably can get from the request object. So after register request, you'd get the access token in the response.
Here is my current snippet. You need to add a custom remote method in your
common/models/account.jsfile (or whatever name you choose) where yourAccountModel inherits the built-inUserModel:Edit: Since the
AccountModel inherits the built-inUserModel, you need to open the Access Control Lists (ACLs) to $everyone.So your
common/models/account.jsonfile should look like this: