added views and Authclients
This commit is contained in:
25
lib/User/AuthClient/Facebook.php
Normal file
25
lib/User/AuthClient/Facebook.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace Da\User\AuthClient;
|
||||
|
||||
use Da\User\Contracts\AuthClientInterface;
|
||||
|
||||
class Facebook extends \yii\authclient\clients\Facebook implements AuthClientInterface
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getEmail()
|
||||
{
|
||||
return isset($this->getUserAttributes()['email'])
|
||||
? $this->getUserAttributes()['email']
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getUsername()
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
27
lib/User/AuthClient/GitHub.php
Normal file
27
lib/User/AuthClient/GitHub.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace Da\User\AuthClient;
|
||||
|
||||
use Da\User\Contracts\AuthClientInterface;
|
||||
|
||||
class GitHub extends \yii\authclient\clients\GitHub implements AuthClientInterface
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getEmail()
|
||||
{
|
||||
return isset($this->getUserAttributes()['email'])
|
||||
? $this->getUserAttributes()['email']
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getUsername()
|
||||
{
|
||||
return isset($this->getUserAttributes()['login'])
|
||||
? $this->getUserAttributes()['login']
|
||||
: null;
|
||||
}
|
||||
}
|
||||
25
lib/User/AuthClient/Google.php
Normal file
25
lib/User/AuthClient/Google.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace Da\User\AuthClient;
|
||||
|
||||
use Da\User\Contracts\AuthClientInterface;
|
||||
|
||||
class Google extends \yii\authclient\clients\Google implements AuthClientInterface
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getEmail()
|
||||
{
|
||||
return isset($this->getUserAttributes()['emails'][0]['value'])
|
||||
? $this->getUserAttributes()['emails'][0]['value']
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getUsername()
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
25
lib/User/AuthClient/LinkedIn.php
Normal file
25
lib/User/AuthClient/LinkedIn.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace Da\User\AuthClient;
|
||||
|
||||
use Da\User\Contracts\AuthClientInterface;
|
||||
|
||||
class LinkedIn extends \yii\authclient\clients\LinkedIn implements AuthClientInterface
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getEmail()
|
||||
{
|
||||
return isset($this->getUserAttributes()['email-address'])
|
||||
? $this->getUserAttributes()['email-address']
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getUsername()
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
26
lib/User/AuthClient/Twitter.php
Normal file
26
lib/User/AuthClient/Twitter.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
namespace Da\User\AuthClient;
|
||||
|
||||
use Da\User\Contracts\AuthClientInterface;
|
||||
|
||||
|
||||
class Twitter extends \dektrium\user\clients\Twitter implements AuthClientInterface
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUsername()
|
||||
{
|
||||
return isset($this->getUserAttributes()['screen_name'])
|
||||
? $this->getUserAttributes()['screen_name']
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null Twitter does not provide user's email address
|
||||
*/
|
||||
public function getEmail()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
39
lib/User/AuthClient/VKontakte.php
Normal file
39
lib/User/AuthClient/VKontakte.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace Da\User\AuthClient;
|
||||
|
||||
use Da\User\Contracts\AuthClientInterface;
|
||||
use Yii;
|
||||
|
||||
class VKontakte extends \yii\authclient\clients\VKontakte implements AuthClientInterface
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public $scope = 'email';
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getEmail()
|
||||
{
|
||||
return $this->getAccessToken()->getParam('email');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getUsername()
|
||||
{
|
||||
return isset($this->getUserAttributes()['screen_name'])
|
||||
? $this->getUserAttributes()['screen_name']
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function defaultTitle()
|
||||
{
|
||||
return Yii::t('user', 'VKontakte');
|
||||
}
|
||||
}
|
||||
42
lib/User/AuthClient/Yandex.php
Normal file
42
lib/User/AuthClient/Yandex.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
namespace Da\User\AuthClient;
|
||||
|
||||
use Da\User\Contracts\AuthClientInterface;
|
||||
use Yii;
|
||||
|
||||
class Yandex extends \yii\authclient\clients\Yandex implements AuthClientInterface
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getEmail()
|
||||
{
|
||||
$emails = isset($this->getUserAttributes()['emails'])
|
||||
? $this->getUserAttributes()['emails']
|
||||
: null;
|
||||
|
||||
if ($emails !== null && isset($emails[0])) {
|
||||
return $emails[0];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getUsername()
|
||||
{
|
||||
return isset($this->getUserAttributes()['login'])
|
||||
? $this->getUserAttributes()['login']
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function defaultTitle()
|
||||
{
|
||||
return Yii::t('user', 'Yandex');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user