See also: See also: 用户认证和授权
LoopBack's built-in User model provides essential user management features such as:
- Registration and confirmation via email.
- Login and logout.
- Creating an access token.
- Password reset.
You can extend the User model to suit your specific needs, so in most cases, you don't need to create your own User model from scratch.
The basic process to create and authenticate users is:
- Register a new user with the
User.create()
method, inherited from the genericPersistedModel
object. See Registering users for more information. - Log in a user by calling
User.login()
to get an access token. See Logging in users for more information. - Make subsequent API calls using the access token. Provide the access token in the HTTP header or as a query parameter to the REST API call, as shown in Making authenticated requests with access tokens.