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
333 Views Asked by Felix Olondea At
2
There are 2 best solutions below
0

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.js
file (or whatever name you choose) where yourAccount
Model inherits the built-inUser
Model:Edit: Since the
Account
Model inherits the built-inUser
Model, you need to open the Access Control Lists (ACLs) to $everyone.So your
common/models/account.json
file should look like this: