rmrevin/yii2-ulogin Extension for yii2 ulogin integration

uloginoauthauthorization

ULogin integration for Yii 2

Installation

The preferred way to install this extension is through composer.

Either run

composer require "rmrevin/yii2-ulogin:~1.4"

or add

"rmrevin/yii2-ulogin": "~1.4",

to the require section of your composer.json file.

Usage

use rmrevin\yii\ulogin\ULogin;

echo ULogin::widget([
    // widget look'n'feel
    'display' => ULogin::D_PANEL,

    // required fields
    'fields' => [ULogin::F_FIRST_NAME, ULogin::F_LAST_NAME, ULogin::F_EMAIL, ULogin::F_PHONE, ULogin::F_CITY, ULogin::F_COUNTRY, ULogin::F_PHOTO_BIG],

    // optional fields
    'optional' => [ULogin::F_BDATE],

    // login providers
    'providers' => [ULogin::P_VKONTAKTE, ULogin::P_FACEBOOK, ULogin::P_TWITTER, ULogin::P_GOOGLE],

    // login providers that are shown when user clicks on additonal providers button
    'hidden' => [],

    // where to should ULogin redirect users after successful login
    'redirectUri' => ['sign/ulogin'],

    // force use https in redirect uri
    'forceRedirectUrlScheme' => 'https',

    // optional params (can be ommited)
    // force widget language (autodetect by default)
    'language' => ULogin::L_RU,

    // providers sorting ('relevant' by default)
    'sortProviders' => ULogin::S_RELEVANT,

    // verify users' email (disabled by default)
    'verifyEmail' => '0',

    // mobile buttons style (enabled by default)
    'mobileButtons' => '1',
]);

Getting user info after success auth (response from ulogin):

use rmrevin\yii\ulogin\AuthAction;

class SiteController extends Controller
{

    public function action()
    {
        return [
            // ...
            'ulogin-auth' => [
                'class' => AuthAction::className(),
                'successCallback' => [$this, 'uloginSuccessCallback'],
                'errorCallback' => function($data){
                    \Yii::error($data['error']);
                },
            ]
        ];
    }

    public function uloginSuccessCallback($attributes)
    {
        print_r($attributes);
    }
}

Changelog

1.4.0 - 20.06.2018

  • Add force http scheme in redirect uri.
  • Update packages.
  • Refactoring.

16.11.2015

  • Add method ULogin::getUserAttributes($token).
  • Add action for response from ulogin.
  • Deprecated: renamed Widget::$lang to Widget::$language.
  • Deprecated: renamed Widget::$redirect_uri to Widget::$redirectUri.
  • Deprecated: renamed Widget::$execute_custom_init to Widget::$executeCustomInit.

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



1.4.0 is the latest of 11 releases



MIT license
Stats
15 github stars & 9 github forks
3 downloads in the last day
39 downloads in the last 30 days
11276 total downloads