🔁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

Login

post

We are using bearer token auth system and you can get token by using this APIs.

Body
emailstringRequired
passwordstringRequired
Responses
200
A user resource with Token.
application/json
post
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"
  }
}

Register

post

You can create a new account by use this API.

Body
namestringRequired
phonestringRequired
emailstring · emailRequired
passwordstringRequired
front_idstring · binaryRequired
back_idstring · binaryRequired
relation_typeinteger | nullOptional
parent_idintegerOptional
password_confirmationstringRequired
Responses
200Success
application/json
Responseany of
or
post
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"
  }
}

Reset Password

post

You can send reset password request by use this APIs.

Body
emailstringRequired
Responses
200
OTP Send Success Using Service Provider.
application/json
post
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"
}

Resend OTP

post

You can resend OTP by use this API.

Body
emailstringRequired
Responses
200
OTP Send Success Using Service Provider.
application/json
post
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"
}

Check OTP & Active Account

post

You can check OTP is vaild by use this API and active the user if it's vaild.

Body
emailstringRequired
otp_codestringRequired
Responses
200
OTP is vaild and the account has been activated.
application/json
post
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"
}

Check OTP

post

You can check OTP is vaild by use this API.

Body
emailstringRequired
otp_codestringRequired
Responses
200
OTP is vaild and the account has been activated.
application/json
post
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"
}

Change Password

post

If the request of change password has been send success you can change the password with OTP form here.

Body
passwordstringRequired
password_confirmationstringRequired
Responses
200
OTP is vaild and the password has been changed.
application/json
post
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

User Profile

get

You Can Return user resource data from this APIs.

Responses
200
A user resource with Token.
application/json
get
GET /api/profile HTTP/1.1
Host: cm.test
Accept: */*
{
  "status": true,
  "message": "Profile Data Load",
  "data": {}
}

Update User Profile

post

You can update user data by use this APIs.⚠️Cannot generate request documentation: Undefined variable $user

Responses
200
A user resource with Token.
application/json
post
POST /api/profile HTTP/1.1
Host: cm.test
Accept: */*
{
  "status": true,
  "message": "Profile Data Update",
  "data": {}
}

Update User Password

post

You can update user password by use this APIs.

Body
passwordstringRequired
password_confirmationstringRequired
Responses
200
If Your Has Token He Can change the password direct without OTP.
application/json
post
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"
}

Close Account

delete

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.

Body
objectOptional
Responses
200
The account has been close you can register again
application/json
delete
DELETE /api/profile/destroy HTTP/1.1
Host: cm.test
Content-Type: application/json
Accept: */*
Content-Length: 2

{}
200

The account has been close you can register again

{
  "status": true,
  "message": "Account Has Been Deleted"
}

Logout User

post

You can logout the user by destory tokens and session by use this API.

Body
objectOptional
Responses
200
The user logout success and the tokens destoried.
application/json
post
POST /api/profile/logout HTTP/1.1
Host: cm.test
Content-Type: application/json
Accept: */*
Content-Length: 2

{}
200

The user logout success and the tokens destoried.

{
  "status": true,
  "message": "Logout Success"
}

Last updated

Was this helpful?