infotechnohelp/cakephp-auth-api

CakePHP 3 api plugin for authentication

Installs: 1 313

Dependents: 2

Suggesters: 0

Security: 0

Stars: 0

Forks: 0

Type:cakephp-plugin

2.0.4 2019-03-07 11:13 UTC

This package is auto-updated.

Last update: 2024-04-08 06:24:27 UTC


README

  • composer require infotechnohelp/cakephp-auth-api

  • App/config/bootstrap.php

Plugin::load('AuthApi', ['routes' => true]);

or

bin/cake plugin load AuthApi -r

  • bin/cake migrations migrate --plugin AuthApi

  • App/src/Controller/AppController.php

class AppController extends \AuthApi\Controller\AppController

Register a new user

bin/cake AuthApi.users register <username> <password> <user_role_id>

Usage in controllers

By default, all controllers will have a forbidden access.

In order to allow a controller's method:

    public function initialize()
    {
        parent::initialize();
        $this->Auth->allow('allowedMethod');
    }

API

  • APP/auth-api/register → username, password, repeat-password (email, user_role_id)

{"data":entity, "message": null}

{"data":null, "message": message text}

  • APP/auth-api → username, password

{"data":entity, "message": null}

{"data":null, "message": Error message text}

  • APP/auth-api/logout

{"data":true, "message": null}