2017 © Pedro Peláez
 

yii2-extension yii2-megaplanauth

Provides ability to auth users using Megaplan Auth API

image

leammas/yii2-megaplanauth

Provides ability to auth users using Megaplan Auth API

  • Thursday, July 9, 2015
  • by leammas
  • Repository
  • 2 Watchers
  • 0 Stars
  • 50 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 2 % Grown

The README.md

Yii2 Megaplan Auth Client

Provides ability to auth users using Megaplan Auth API Specification can be found there., (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist leammas/yii2-megaplanauth "*"

or add, (*4)

"leammas/yii2-megaplanauth": "*"

to the require section of your composer.json file., (*5)

Requirements

  • Yii2
  • PHP 5.4+
  • Curl and php-curl installed

Usage

Once the extension is installed, use it as application component :, (*6)

    'components' => [
        ...
        'mpauth' => [
            'class' => 'leammas\yii2\megaplanauth\Megaplanauth',
            'url' => 'http://some.url',
            'timeout' => 10
        ],
        ...

The main method authenticate accepts two parameters username and password. Use it somewhere in your form or user model validation. It will return array with user data if succeed or throw MPAuthException with error message., (*7)

    /**
     * @param $password
     * @return bool
     */
    public function validatePassword($password)
    {
        try
        {
            $success = Yii::$app->mpauth->authenticate($this->username, $password);
            // if you don't use Megaplan user id's or employee id's, just replace it with `return true;`
            return $success['EmployeeId'] == $this->id;
        }
        catch(MPAuthException $e)
        {
            Yii::trace('MPAuth Fail: ' . $e->getMessage());
            return false;
        }
    }

The Versions

09/07 2015

dev-master

9999999-dev

Provides ability to auth users using Megaplan Auth API

  Sources   Download

MIT

The Requires

 

by Avatar leammas

extension auth yii2 megaplan