Files
Zumri-Backend/Documentation/Auth-API.md
T
Isuru Bimsara 81d0e65686 first commit
2026-08-14 22:46:02 +05:30

125 lines
1.4 KiB
Markdown

# Auth API
#### Request OTP
**Endpoint**
```
POST: http://localhost:3070/api/auth/req-otp
```
**Request Body**
```json
{
"email": "sathira@niolla.lk",
"password": "Niolla@123"
}
```
**Respond**
```json
{
"success": true,
"message": "OTP Sent Successfully"
}
```
---
#### Login
**Endpoint**
```
POST: http://localhost:3070/api/auth/login
```
**Request Body**
```json
{
"email": "sathira@niolla.lk",
"otp": "922304"
}
```
**Respond**
```json
{
"success": true,
"message": "Login Successful",
"data": {
"id": "usr_5ff8afec-5ddc-47d9-a63f-b43df0d8c3b4",
"email": "sathira@niolla.lk",
"firstName": "Jhon",
"lastName": "Doe",
"role": "System Developer",
"accountType": "admin"
}
}
```
---
#### Get Current User
**Endpoint**
```
GET: http://localhost:3070/api/auth/me
```
**Authorization**: Required (Bearer token)
**Request Body**
```
No Body
```
**Response (200)**
```json
{
"authenticated": true,
"user": {
"id": "usr_5ff8afec-5ddc-47d9-a63f-b43df0d8c3b4",
"firstName": "Sathira",
"lastName": "Sri Sathsara",
"email": "sathira@niolla.lk",
"role": "System Developer",
"accountType": "admin",
"iat": 1778865265,
"exp": 1778868865,
"permissions": []
}
}
```
---
### Logout
**Endpoint**
```
POST: http://localhost:3070/api/auth/logout
```
**Request Body**
```
No Body
```
**Respond**
```json
{
"success": true,
"message": "Logged out successfully"
}
```