dev-master
9999999-devProvides ability to auth users using Megaplan Auth API
MIT
The Requires
by leammas
extension auth yii2 megaplan
Provides ability to auth users using Megaplan Auth API
Provides ability to auth users using Megaplan Auth API Specification can be found there., (*1)
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)
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; } }
Provides ability to auth users using Megaplan Auth API
MIT
extension auth yii2 megaplan