Users (& Clients)
Users and clients are treated the same for a large part. But there actually is major difference (see below).
After authentication both will be represented as implementations of Swift\Security\User\UserInterface
for easy usage throughout the application.
#
UsersUsers are end users of the application (e.g. customers, etc.)
Swift\Security\User\ClientUser
)#
Clients (Clients represent API Consumers.
#
EndpointsSwift comes with a ready to use users endpoint for the following actions:
#
For users- Create user account (REST & GraphQl)
- Login (REST & GraphQl)
- Me (REST & GraphQl) returns currently authenticated user
- List Users (REST & GraphQl)
- User by id (REST & GraphQl)
- Forgot password (REST & GraphQl) generates a 30 minutes valid reset token
- Reset password (REST & GraphQl) create new user password
#
For clients- Get (Oauth) token (REST & GraphQl)
- Refresh (Oauth) token (REST & GraphQl)
#
Forgot- and reset passwordWhen a user has forgotten it's password a special token is required to reset it. This available with REST and GraphQl (see example below).
#
Forgot passwordForgt password endpoinsts
#
Example: RESTRequest (/users/password/forgot/) POST
Response
#
Example: GraphQlRequest (/users/password/forgot/) POST
Response
#
Reset passwordAs you can see in the example above the resetPasswordToken is not returned directly for security reasons. The system does also not send any communication to the user with the token automatically since it's highly likely you'd want to moderate this message to the user anyway. So you'll need to listen to the Event and notify the user of the token.
#
Example: Notify user of tokenSee below how this could be achieved. You'd obviously want to do this different, but it gives you an idea.
#
Reset Password Example: RestRequest (/users/password/reset/) POST
Response
#
Reset Password Example: GraphQlRequest