Auth - Documentation

# Auth

### Members

#### (route) requestNewPassword

##### Route:

Method | Path
--- | ---
POST | /api/oauth/reset_password

Send a request to reset the password of a account via its email

##### Service:

Any call to this endpoint need to be done on service : OAUTH

##### Body Parameters:

Name | Type | Description
--- | --- | ---
email | String | email of the account that want a password reset

##### Response Code:

Type | Description
--- | ---
500 | the database failed to register the token to reset the mail
400 | missing parameters
404 | no user account where found with the provided email
200 | the mail has been sent to the provided email

#### (route) retrieveToken

##### Route:

Method | Path
--- | ---
POST | /api/oauth/token

Ask for an access token on the behalf of an user using a refresh token

##### Service:

Any call to this endpoint need to be done on service : OAUTH

##### Body Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
client_id | String |  | the public id of your oauth application
refresh_token | String |  | refresh token you retrieved via authorize endpoint
grant_type | String | refresh_token |

##### Response:

Name | Type | Description
--- | --- | ---
access_token | String | a fresh access_token
refresh_token | String | the refresh token you used
expire_at | String | UTC date at which the token will be considered as invalid
token_type | String | the type of token to use, for now its always Bearer

##### Response Code:

Type | Description
--- | ---
400 | invalid parameters (missing or not correct)

#### (route) sendEmailLink

##### Route:

Method | Path
--- | ---
POST | /api/oauth/send_email_link

Send a request to valid account via its email

##### Service:

Any call to this endpoint need to be done on service : OAUTH

##### Response Code:

Type | Description
--- | ---
500 | the database failed to register the token to reset the mail
401 | need to authenticated
200 | the mail has been sent to the provided email

#### (route) validEmail

##### Route:

Method | Path
--- | ---
GET | /api/oauth/valid_email/:token

Valid user email with a token

##### Service:

Any call to this endpoint need to be done on service : OAUTH

##### Route Parameters:

Name | Type | Description
--- | --- | ---
:token | undefined | the token to validate the account

##### Response Code:

Type | Description
--- | ---
500 | the database failed to valid email
404 | need to authenticated
301 | the email has been valided

### Methods

#### (route) register()

##### Route:

Method | Path
--- | ---
GET | /api/oauth/register

Register a new user

##### Service:

Any call to this endpoint need to be done on service : OAUTH

##### Body Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
username | String |  |
email | String |  |
password | String |  |
role | String | optional | job title in user company
company | String | optional | company name
accept_terms | Integer |  |

##### Response:

Name | Type | Description
--- | --- | ---
user | Object | user model
access_token | Object | access token issued for the user
refreshToken | Object | refresh token issued for the user

##### Response Code:

Type | Description
--- | ---
500 | either the registeration of new user is disabled or the database failed to register the user
409 | the user field are already used by another user
200 | the user has been created

#### (route) revoke()

##### Route:

Method | Path
--- | ---
POST | /api/oauth/revoke

Revoke a refresh token

##### Authentication

A authentication is needed to access this endpoint

##### Service:

Any call to this endpoint need to be done on service : OAUTH

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Response Code:

Type | Description
--- | ---
404 | token not found
500 | database error
200 | the token has been succesfully deleted, if there was access token generated with this token, they have been deleted too