-
Notifications
You must be signed in to change notification settings - Fork 2
4. How to use
AspNet project provides automatically of a Controller exposing the following actions:
-
Login action: receiving the credentials, by username, email or phone, and returning the Session for the user if allowed to authenticate
-
Task LoginAsync([FromBody] Credentials credentials)
-
POST
-
[...]/api/auth/login
-
Examples
- For Email login:
{ "Email": "[email protected]", "Password": "Test.1234" }
- For Phone login:
{ "Phone": "666999666", "Password": "Test.1234" }
- For Username login:
{ "UserName": "TestUser", "Password": "Test.1234" }
-
-
Register action: receiving credentials, and creating an entry for that user in the database
- Task RegisterAsync([FromBody] Credentials credentials)
- POST
- [...]/api/auth/register
- Example
- JSON body for whole registration, but phone and culture are optional:
{ "Username": "TestUser", "Email": "[email protected]", "Password": "Test.1234", "Phone": "666777999" }
-
Confirm action: receiving the confirmation token for a user email or phone, confirming this mechanism for login
- Task ConfirmAsync([FromBody] UserValidation userValidation)
- POST
- [...]/api/auth/confirm
- Examples:
- Confiming email:
{ "Email": "[email protected]", "ConfirmationToken": "_wholeTokenGeneratedByAuthForEmail_" }
- Confiming phone:
{ "Phone": "666777999", "ConfirmationToken": "_wholeTokenGeneratedByAuthForPhone_" }
-
Activate/Deactivate action: receiving the user and flag for activate or deactivate the user
- Task ActivateAsync([FromBody] UserActivation userActivation)
- POST
- [...]/api/auth/activate
- Example
- Deactivate user
{ "Username": "TestUser", "Password": "Test.1234", "Activate": false }
- Activate user
{ "Username": "TestUser", "Password": "Test.1234", "Activate": true }
In most cases, Session object will be retrived giving the following information, depending on the configuration could for example send some parameters such as Confirmation Tokens for Email and/or phone:
- UserId
- Username
- Token
- ExpirationDate
- Culture
- Parameters (depending on configuration)