added views and Authclients

This commit is contained in:
Antonio Ramirez
2016-12-10 20:55:17 +01:00
parent 1c863f815a
commit 6d47dcaf22
41 changed files with 1876 additions and 5 deletions

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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');
}
}

View 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');
}
}