🔁APIs
you can show the APIs Endpoints here
you can activate this feature or stop it from the config file and use your own routes or your own controllers.
to make this endpoint work fine you need to add a custom gruid inside /config/auth.php
to be like this
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'accounts' => [
'driver' => 'session',
'provider' => 'accounts',
]
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
'accounts' => [
'driver' => 'eloquent',
'model' => \TomatoPHP\TomatoCrm\Models\Account::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expiry time is the number of minutes that each reset token will be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
| The throttle setting is the number of seconds a user must wait before
| generating more password reset tokens. This prevents the user from
| quickly generating a very large amount of password reset tokens.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_reset_tokens',
'expire' => 60,
'throttle' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Password Confirmation Timeout
|--------------------------------------------------------------------------
|
| Here you may define the amount of seconds before a password confirmation
| times out and the user is prompted to re-enter their password via the
| confirmation screen. By default, the timeout lasts for three hours.
|
*/
'password_timeout' => 10800,
];
Auth Endpoints
We are using bearer token auth system and you can get token by using this APIs.
POST /api/login HTTP/1.1
Host: cm.test
Content-Type: application/json
Accept: */*
Content-Length: 34
{
"email": "text",
"password": "text"
}
{
"status": true,
"message": "Data Retrieved Successfully",
"data": {
"token": "text"
}
}
You can create a new account by use this API.
POST /api/register HTTP/1.1
Host: cm.test
Content-Type: multipart/form-data
Accept: */*
Content-Length: 178
{
"name": "text",
"phone": "text",
"email": "[email protected]",
"password": "text",
"front_id": "binary",
"back_id": "binary",
"relation_type": null,
"parent_id": 1,
"password_confirmation": "text"
}
{
"status": true,
"message": "User registration success",
"data": {
"token": "text"
}
}
You can send reset password request by use this APIs.
POST /api/reset HTTP/1.1
Host: cm.test
Content-Type: application/json
Accept: */*
Content-Length: 16
{
"email": "text"
}
{
"status": true,
"message": "An OTP Has been send to your email please check it"
}
You can resend OTP by use this API.
POST /api/resend HTTP/1.1
Host: cm.test
Content-Type: application/json
Accept: */*
Content-Length: 16
{
"email": "text"
}
{
"status": true,
"message": "An OTP Has been send to your email please check it"
}
You can check OTP is vaild by use this API and active the user if it's vaild.
POST /api/otp HTTP/1.1
Host: cm.test
Content-Type: application/json
Accept: */*
Content-Length: 34
{
"email": "text",
"otp_code": "text"
}
{
"status": true,
"message": "your Account has been activated"
}
You can check OTP is vaild by use this API.
POST /api/otp-check HTTP/1.1
Host: cm.test
Content-Type: application/json
Accept: */*
Content-Length: 34
{
"email": "text",
"otp_code": "text"
}
{
"status": true,
"message": "your Account has been activated"
}
If the request of change password has been send success you can change the password with OTP form here.
POST /api/password HTTP/1.1
Host: cm.test
Content-Type: application/json
Accept: */*
Content-Length: 50
{
"password": "text",
"password_confirmation": "text"
}
{
"status": true,
"message": "Password Updated"
}
Profile Endpoints
You can update user data by use this APIs.⚠️Cannot generate request documentation: Undefined variable $user
POST /api/profile HTTP/1.1
Host: cm.test
Accept: */*
{
"status": true,
"message": "Profile Data Update",
"data": {}
}
You can update user password by use this APIs.
POST /api/profile/password HTTP/1.1
Host: cm.test
Content-Type: application/json
Accept: */*
Content-Length: 50
{
"password": "text",
"password_confirmation": "text"
}
{
"status": true,
"message": "Password Updated"
}
You can close your account by send this request, please note that all data for this user will be deleted and you can register again.
DELETE /api/profile/destroy HTTP/1.1
Host: cm.test
Content-Type: application/json
Accept: */*
Content-Length: 2
{}
The account has been close you can register again
{
"status": true,
"message": "Account Has Been Deleted"
}
You can logout the user by destory tokens and session by use this API.
POST /api/profile/logout HTTP/1.1
Host: cm.test
Content-Type: application/json
Accept: */*
Content-Length: 2
{}
The user logout success and the tokens destoried.
{
"status": true,
"message": "Logout Success"
}
Last updated
Was this helpful?