# Account Creation and Authentication

Account creation is necessary in order for the application to be utilized effectively. There are two main categories of registration:

{% tabs %}
{% tab title="Admin Registration" %}
This type of account registration is targeted towards the administrative users of the application, as they have more privileged access to the API service of Elixir. Registration is done with an endpoint specifically designed for administrative registration. Requirements include a unique email address and a password.

`curl -X POST`\
`api/v1/auth/`register-admin\
`-H 'Content-Type: application/json'`\
`-d '{ "email": "user@example.com", "password": "password123" }'`
{% endtab %}

{% tab title="User Registration" %}
When it comes to user registration, however, this category is further broken down into two more subcategories:

### 1. Medical Provider's Registration

In this category of registration, medical providers are registered in various medical departments as **consultants** and **non-consultants.** &#x20;

#### Registration as a Consultant

To register as a consultant into a department, special endpoints are already defined in the format of `api/v1/auth/registration-consultant-<department>`

The required data for this form of registration includes:

* email
* first name
* last name
* telephone
* address

With the use of these endpoints, the "department" data does not have to be specified.

#### Registration as a Non-Consultant

This form of registration is slightly different from the initial. The data on which department the doctor is being registered into, as well as hierarchy should be specified.

* email
* first name
* last name
* password
* department
* telephone
* address
* hierarchy

The endpoint for this form of registration:

`api/v1/auth/register-doctor`

{% hint style="info" %}
If no hierarchy is specified, the medical provider is registered in the department as an **Associate Specialist.** Every other field is **compulsory.**
{% endhint %}

Once a consultant is registered, a group is created in the medical department registered into. A group has a maximum of :

* 1 consultant
* 2 associate specialists
* 4 junior doctors, and
* 8 medical students

### 2.  Patient's Registration

This class of registration is created for the administrative users. An email and a password is simply needed. This automatically creates a profile for the patients. The patient will have to fill in the needed data later on. These includes:

* first name
* last name
* age
* address
* telephone
* occupation
* marital status.

Though these are the fields required to set up a complete patient's profile, the complete data includes:

* doctor's name
* doctor's telephone
* doctor's email
* doctor's department
* email
  {% endtab %}
  {% endtabs %}

Authentication/Authorization methods include:

* Json Web Tokens
* OAuth2.0 / Auth0 (for patient registration)

<figure><img src="https://350429662-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGC18mL4MKZlKGZMfxjHj%2Fuploads%2FBnJnKaJE1VtiGFTFCaS3%2FScreenshot%20from%202023-06-06%2019-01-06.png?alt=media&#x26;token=554d818c-885d-4b86-9d45-2b5d213deae3" alt=""><figcaption></figcaption></figure>

Password change and reset endpoints are also made available.

```
POST token/forgot-password
```

```
POST auth/change-password
```
