1. Go to this page and download the library: Download sergmoro1/yii2-user library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
public function getAvatarImage()
{
return $this->getImage('thumb');
}
namespace frontend\controllers;
use Yii;
use sergmoro1\user\traits\AuthTrait;
class SiteController extends Controller
{
use AuthTrait;
/**
* Handler for EVENT_AFTER_LOGGED_IN. May be defined if needed.
*/
public function init()
{
parent::init();
$this->on(\sergmoro1\user\Module::EVENT_AFTER_LOGGED_IN, function($event) { Yii::$app->session->setFlash('success',
Yii::t('app', 'You are logged in as a commentator. You can leave a comment now.'));
});
}
/**
* inheritdoc
*/
public function actions()
{
return [
'auth' => [
'class' => 'yii\authclient\AuthAction',
'successCallback' => [$this, 'onAuthSuccess'],
],
];
}