Login and Registration
This guide explains how to implement user login and registration in the Sumaya369 web application.
User Registration
Endpoint
- Method: POST
- URL:
/v1/customer/register
Request Headers
| Header | Value | Required |
|---|---|---|
| Content-Type | application/json | Yes |
| Accept | application/json | Yes |
Request Body
| Parameter | Type | Description | Required |
|---|---|---|---|
| full_name | string | User's full name | Yes |
| string | User's email address | Yes | |
| password | string | User's password (min 6 characters) | Yes |
| country_id | string | UUID of user's country | Yes |
| phone | string | User's phone number | Yes |
| has_read_policy | boolean | Acceptance of terms | Yes |
| avatar | file | Optional profile picture | No |
Success Response
{
"success": true,
"message": "تم التسجيل بنجاح.",
"data": {
"id": "0a79add0-f3ae-11ef-bee7-8bfdde00797d",
"username": "testing_1",
"first_name": null,
"last_name": null,
"full_name": "Ahmed Mohammad",
"country_name": "السعودية",
"email": "testing@gmail.com",
"birth": null,
"phone": "966555545539",
"gender": null,
"avatar": "https://i.ibb.co/YhTw0wR/7-512.png",
"token": "token_here",
"token_type": "Bearer"
},
"status_code": 200
}
Error Responses
Validation Error (422)
{
"success": false,
"message": "قيمة البريد الإلكتروني مُستخدمة من قبل.",
"errors": null,
"data": null,
"status_code": 422
}
Resend Activation Email
Endpoint
- Method: POST
- URL:
/v1/customer/resend-activation-email
Request Headers
| Header | Value | Required |
|---|---|---|
| Content-Type | application/json | Yes |
| Accept | application/json | Yes |
Request Body
| Parameter | Type | Description | Required |
|---|---|---|---|
| string | Registered email address | Yes |
Success Response
{
"success": true,
"message": "تم إرسال رسالة التفعيل إلى بريدك الإلكتروني",
"data": null,
"status_code": 200
}
Error Responses
Already Activated (200)
{
"success": true,
"message": "بريدك الإلكتروني مفعل مسبقاً",
"data": null,
"status_code": 200
}
Too Many Requests (310)
{
"success": false,
"message": "لقد تم إرسال رابط التفعيل إلى بريدك الإلكتروني يمكنك إرسال رسالة أخرى بعد ثلاثة دقائق",
"errors": "لقد تم إرسال رابط التفعيل إلى بريدك الإلكتروني يمكنك إرسال رسالة أخرى بعد ثلاثة دقائق",
"data": null,
"status_code": 310
}
Account Activation
Endpoint
- Method: POST
- URL:
/v1/customer/activate-account
Request Headers
| Header | Value | Required |
|---|---|---|
| Content-Type | application/json | Yes |
| Accept | application/json | Yes |
Request Body
| Parameter | Type | Description | Required |
|---|---|---|---|
| string | Registered email address | Yes | |
| token | string | 60-character activation token | Yes |
Success Response
{
"success": true,
"message": "تم تفعيل بريدك الإلكتروني بنجاح.",
"data": {
"email": "testing@gmail.com"
},
"status_code": 200
}
Error Responses
Invalid Token (422)
{
"success": false,
"message": "رمز التحقق هذا غير صحيح.",
"errors": "رمز التحقق هذا غير صحيح.",
"data": null,
"status_code": 404
}
User Login
Endpoint
- Method: POST
- URL:
/v1/customer/login
Request Headers
| Header | Value | Required |
|---|---|---|
| Content-Type | application/json | Yes |
| Accept | application/json | Yes |
Request Body
| Parameter | Type | Description | Required |
|---|---|---|---|
| string | User's email or username | Yes | |
| password | string | User's password | Yes |
| fcm_token | string | Firebase Cloud Messaging token | No |
| device_id | string | Unique device identifier | Required with fcm_token |
| products | array | Cart items to synchronize | No |
Success Response
{
"success": true,
"message": "تم تسجيل الدخول بنجاح.",
"data": {
"id": "0a79add0-f3ae-11ef-bee7-8bfdde00797d",
"first_name": null,
"last_name": null,
"full_name": "Ahmed Mohammad",
"country_name": "السعودية",
"email": "testing@gmail.com",
"birth": null,
"phone": "966555545539",
"gender": null,
"has_completed_profile": true,
"token": "token_here",
"token_type": "Bearer"
},
"status_code": 200
}
Error Responses
Invalid Credentials (401)
{
"status": false,
"message": "بيانات الاعتماد غير صحيحة",
"data": null
}
Logout
Endpoint
- Method: POST
- URL:
/v1/customer/logout
Request Headers
| Header | Value | Required |
|---|---|---|
| Content-Type | application/json | Yes |
| Accept | application/json | Yes |
| Authorization | Bearer token | Yes |
Request Body
| Parameter | Type | Description | Required |
|---|---|---|---|
| device_id | string | Device identifier to remove from registered devices | No |
Success Response
{
"success": true,
"message": "تم تسجيل الخروج بنجاح.",
"data": null,
"status_code": 200
}
Example Implementation Flow
-
User Registration Process
- User fills out registration form
- Application sends registration request to
/v1/customer/register - User receives activation email
- User activates account via
/v1/customer/activate-account - If activation email is not received, user can request a new one via
/v1/customer/resend-activation-email
-
Login Process
- User enters email and password
- Application sends login request to
/v1/customer/login - Upon successful authentication:
- Receive access token
- Store user information
- Synchronize cart items (if applicable)
- Navigate to main application screen
Key Considerations
- Always use HTTPS for all authentication requests
- Securely store tokens and user information
- Handle authentication errors gracefully
- User isn't required to activate email to have full access to the application