🖥️
SIM-REST
  • Overview
  • Getting Started
  • Authentication
  • Routes
    • Methods
    • Protected Routes
  • Database
    • DB Query
  • Filter data
  • Helper
  • Session
Powered by GitBook
On this page
  • Admin Users
  • Declare route for Authentication
  • Get Admin User Token

Was this helpful?

Authentication

Admin Users

Add admin users in /database/config.php

token will be auto generated

{
    "admins": [
        {
            "username": "admin1",
            "password": "admin1",
            "token": ""
        },
        {
            "username": "admin2",
            "password": "admin2",
            "token": ""
        }
}

Declare route for Authentication

Add /auth route in index.php

/**
 * Authentication Route
 */
$router->post('/auth',function($payload){
    echo Auth::login($payload);
});

Make sure to import Auth Class

use Auth;

Get Admin User Token

POST -/auth

Request Body

Name
Type
Description

username

string

username of admin

password

string

password of admin

{
    "status": 200,
    "message": "Token generated.",
    "data": {
        "token": "NDFjMjhkMjZkYmRiZGJiMTE4NDZiYTZkODQ4NDcwMzI1NzdiYzJjNjI5Y2Q3MmNmYmYxNGE0YWUyOWU1Njg1ZjU4ZWYzNWM3OWY3NTE0N2FmYzQ0MjM4MGZkNTE0NjRjNzlkNzJiODFhM2RkMjBjMzBhMWM4MWVhNWIxY2U5OWRmMDYxNmIwODdhZDI1Y2EzYTM0N2ExYTAzNzBlNGJlNzBiMTMyMDNjMjZiNTljNGNhNDQwOTBiNDAzMTg0YzU3N2I3MDIzZDg="
    }
}
PreviousGetting StartedNextRoutes

Last updated 5 years ago

Was this helpful?