定制 leammas/yii2-megaplanauth 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

leammas/yii2-megaplanauth

Composer 安装命令:

composer require leammas/yii2-megaplanauth

包简介

Provides ability to auth users using Megaplan Auth API

README 文档

README

Provides ability to auth users using Megaplan Auth API Specification can be found there.

Installation

The preferred way to install this extension is through composer.

Either run

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

or add

"leammas/yii2-megaplanauth": "*"

to the require section of your composer.json file.

Requirements

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

Usage

Once the extension is installed, use it as application component :

    '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.

    /**
     * @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;
        }
    }

统计信息

  • 总下载量: 51
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-03