feat: implement OTP login and password reset functionality with corresponding API endpoints and frontend updates

This commit is contained in:
hamed
2026-06-12 12:54:29 +03:30
parent 8ad983310c
commit 63073c6a42
5 changed files with 753 additions and 102 deletions
+72
View File
@@ -554,3 +554,75 @@ Submit a pre-registration request (doctor or clinic). Public endpoint — no aut
|------|------|---------|
| `VALIDATION_ERROR` | 422 | Invalid type / mobile / name |
| `DUPLICATE_REQUEST` | 409 | Pending request already exists for this mobile |
---
## POST `/api/v1/user/otp-login`
ورود با کد OTP تأییدشده — **فقط کاربران موجود**، کاربر جدید ایجاد نمی‌شود.
**Permission:** `PUBLIC`
### Request Body
```json
{ "uuid": "550e8400-e29b-41d4-a716-446655440000" }
```
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `uuid` | string | ✅ | UUID از `verify-code` (باید قبلاً verify شده باشد) |
### Response `200`
```json
{
"access_token": "eyJ...",
"refresh_token": "...",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token_expires_in": 2592000
}
```
### Error Codes
| Code | HTTP | Description |
|------|------|-------------|
| `ERR_VALIDATION_002` | 422 | uuid ارسال نشده |
| `ERR_AUTH_002` | 400 | uuid نامعتبر یا تأیید نشده |
| `ERR_AUTH_003` | 400 | OTP منقضی شده |
| `ERR_AUTH_005` | 401 | کاربری با این شماره یافت نشد |
---
## POST `/api/v1/user/reset-password`
تغییر رمز عبور با تأیید هویت از طریق OTP.
**Permission:** `PUBLIC`
### Request Body
```json
{
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"new_password": "newpass123"
}
```
| Field | Type | Required | Validation |
|-------|------|----------|------------|
| `uuid` | string | ✅ | UUID از `verify-code` (باید قبلاً verify شده باشد) |
| `new_password` | string | ✅ | حداقل ۶ کاراکتر |
### Response `200`
```json
{
"success": true,
"data": { "message": "رمز عبور با موفقیت تغییر یافت" }
}
```
### Error Codes
| Code | HTTP | Description |
|------|------|-------------|
| `ERR_VALIDATION_001` | 422 | uuid یا new_password نادرست/ناقص |
| `ERR_AUTH_002` | 400 | uuid نامعتبر یا تأیید نشده |
| `ERR_NOT_FOUND_001` | 404 | کاربری با این شماره یافت نشد |