Skip to content

ivc-phampbt/cakephp-authentication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Get Started

This guide will walk you through the steps needed to get this project up and running on your local machine.

Prerequisites

Before you begin, ensure you have the following installed:

  • Docker
  • Docker Compose

Building the Docker Environment

Build and start the containers:

docker-compose up -d --build

Installing Dependencies

docker-compose exec app sh
composer install

Database Setup

Set up the database:

bin/cake migrations migrate

Accessing the Application

The application should now be accessible at http://localhost:34251

How to check

Authentication

I created 2 accounts with the following information (Please run the migration again if you have run it before):

User1
email: pham.bqt@gmail.com
pass: P@ss1234tai

User2
email: pham.bqt2@gmail.com
pass: P@ss1234tai2

To get access token (login):

Ex: How to get access token from this system.

  • Request:
POST http://localhost:34251/login
{
    "email": "pham.bqt@gmail.com",
    "password": "P@ss1234tai"
}
  • Response:

- In case of successful login.

HTTP Status Code: 200
{
  "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJteWFwcCIsInN1YiI6MSwiZXhwIjoxNzEwOTI2NjQ3fQ.Hw12qMLfvEf51wVgEVT1OupSgRRgLyrAUxJugcY36_yMST6NpoNfZ7N0-b7DYYPbaCWQ5evqJf0_ZB6abREgJ0dFYfGano3e7kikIOUB_90sIeo7LBlBJCXvVGLZdtDFw_Qxs_Qqd0rtXiDM3NQ04uFiovVkKZz0DxYVe6y2fA8"
}

- In case of unsuccessful login.

HTTP Status Code: 401
{
    "message": "The Username or Password is Incorrect"
}

The received access token will be used to authenticate requests that require authentication. Access token is generated by JWT(JSON Web Tokens). You can get more details at https://jwt.io/.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published