2017 © Pedro PelĂĄez
 

library cake-auth-jwt

CakePHP plugin for authenticating using JSON Web Tokens and others features

image

rederlo/cake-auth-jwt

CakePHP plugin for authenticating using JSON Web Tokens and others features

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Installation

composer require rederlo/cake-auth-jwt

Config

// src/AppController.php

use AuthTrait;

public function initialize()
{
  parent::initialize();
  Auth::create($this, [
      'model' => 'Users',
      'scope_auth' => ['username' => 'email'],
      'scope_jwt' => ['username' => 'id'],
  ]);
}

cross-origin HTTP request use https://github.com/rederlo/cakephp-cors

New User

public function add()
{
    $users = $this->Users->newEntity();
    if($this->request->is('post')){
        $users = $this->Users->patchEntity($users, $this->request->data());
        if ($this->Users->save($users)) {
            $auth = new AuthFactory();
            //Expected Type Entity
            $auth->create($users);
            $token = $auth->build();
        }
    }
    $this->set(compact('token'));
    $this->set('_serialize', ['token']);
}

Login

public function login()
{
    if ($this->request->is('post')) {
        $user = $this->Auth->identify();
        if ($user) {
            $this->Auth->setUser($user);
            return $this->redirect($this->Auth->redirectUrl());
        }
        $this->Flash->error(__('Usernamme or password Ă­nvalid, try again.'));
    }
}

Params token

$auth = new AuthFactory();
$auth->create($users, ['group_id' => $group_id]);

GetParamsToken

/**
* @return Array
*/
$this->getParamsHeader();

The Versions

13/04 2017

dev-master

9999999-dev https://github.com/rederlo

CakePHP plugin for authenticating using JSON Web Tokens and others features

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication cakephp jwt authenticate

04/04 2017

0.0.1

0.0.1.0 https://github.com/rederlo

CakePHP plugin for authenticating using JSON Web Tokens and others features

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication cakephp jwt authenticate