add admin controller and many updates
This commit is contained in:
@ -1,15 +1,17 @@
|
||||
<?php
|
||||
namespace Da\User\Model;
|
||||
|
||||
/**
|
||||
*
|
||||
* Profile.php
|
||||
*
|
||||
* Date: 4/12/16
|
||||
* Time: 14:57
|
||||
* @author Antonio Ramirez <hola@2amigos.us>
|
||||
*/
|
||||
class Profile
|
||||
{
|
||||
use Da\User\Query\ProfileQuery;
|
||||
use yii\db\ActiveRecord;
|
||||
|
||||
|
||||
class Profile extends ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @return ProfileQuery
|
||||
*/
|
||||
public static function find()
|
||||
{
|
||||
return new ProfileQuery(static::class);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,15 +1,16 @@
|
||||
<?php
|
||||
namespace Da\User\Model;
|
||||
|
||||
/**
|
||||
*
|
||||
* SocialNetworkAccount.php
|
||||
*
|
||||
* Date: 4/12/16
|
||||
* Time: 14:56
|
||||
* @author Antonio Ramirez <hola@2amigos.us>
|
||||
*/
|
||||
class SocialNetworkAccount
|
||||
{
|
||||
use Da\User\Query\SocialNetworkAccountQuery;
|
||||
use yii\db\ActiveRecord;
|
||||
|
||||
class SocialNetworkAccount extends ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @return SocialNetworkAccountQuery
|
||||
*/
|
||||
public static function find()
|
||||
{
|
||||
return new SocialNetworkAccountQuery(static::class);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,15 +1,22 @@
|
||||
<?php
|
||||
namespace Da\User\Model;
|
||||
|
||||
/**
|
||||
*
|
||||
* Token.php
|
||||
*
|
||||
* Date: 4/12/16
|
||||
* Time: 15:17
|
||||
* @author Antonio Ramirez <hola@2amigos.us>
|
||||
*/
|
||||
class Token
|
||||
{
|
||||
use Da\User\Query\TokenQuery;
|
||||
use yii\db\ActiveRecord;
|
||||
|
||||
|
||||
class Token extends ActiveRecord
|
||||
{
|
||||
const TYPE_CONFIRMATION = 0;
|
||||
const TYPE_RECOVERY = 1;
|
||||
const TYPE_CONFIRM_NEW_EMAIL = 2;
|
||||
const TYPE_CONFIRM_OLD_EMAIL = 3;
|
||||
|
||||
/**
|
||||
* @return TokenQuery
|
||||
*/
|
||||
public static function find()
|
||||
{
|
||||
return new TokenQuery(static::class);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
<?php
|
||||
namespace Da\User\Model;
|
||||
|
||||
use Da\User\Helper\AuthHelper;
|
||||
use Da\User\Traits\ModuleTrait;
|
||||
use Da\User\Query\UserQuery;
|
||||
use Da\User\Traits\ContainerTrait;
|
||||
use Da\User\Traits\ModuleTrait;
|
||||
use Yii;
|
||||
use yii\base\NotSupportedException;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\ActiveRecord;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\web\IdentityInterface;
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* User ActiveRecord model.
|
||||
@ -47,6 +47,10 @@ class User extends ActiveRecord implements IdentityInterface
|
||||
* @var string Plain password. Used for model validation.
|
||||
*/
|
||||
public $password;
|
||||
/**
|
||||
* @var array connected account list
|
||||
*/
|
||||
protected $connectedAccounts;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
@ -178,7 +182,7 @@ class User extends ActiveRecord implements IdentityInterface
|
||||
*/
|
||||
public function getIsAdmin()
|
||||
{
|
||||
return $this->getAuthHelper()->isAdmin($this->username);
|
||||
return $this->getAuth()->isAdmin($this->username);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -190,7 +194,7 @@ class User extends ActiveRecord implements IdentityInterface
|
||||
*/
|
||||
public function hasRole($role)
|
||||
{
|
||||
return $this->getAuthHelper()->hasRole($this->id, $role);
|
||||
return $this->getAuth()->hasRole($this->id, $role);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -198,20 +202,17 @@ class User extends ActiveRecord implements IdentityInterface
|
||||
*/
|
||||
public function getProfile()
|
||||
{
|
||||
return $this->hasOne($this->getClassMapHelper()->get('Profile'), ['user_id' => 'id']);
|
||||
return $this->hasOne($this->getClassMap()->get('Profile'), ['user_id' => 'id']);
|
||||
}
|
||||
|
||||
protected $connectedAccounts;
|
||||
|
||||
/**
|
||||
* @return SocialNetworkAccount[] social connected accounts [ 'providerName' => socialAccountModel ]
|
||||
*/
|
||||
public function getSocialNetworkAccounts()
|
||||
{
|
||||
if ($this->connectedAccounts == null) {
|
||||
$accounts = $this->connectedAccounts = $this
|
||||
->hasMany($this->getClassMapHelper()->get('Account'), ['user_id' => 'id'])
|
||||
->all();
|
||||
/** @var SocialNetworkAccount[] $accounts */
|
||||
$accounts = $this->hasMany($this->getClassMap()->get('Account'), ['user_id' => 'id'])->all();
|
||||
|
||||
foreach($accounts as $account) {
|
||||
$this->connectedAccounts[$account->provider] = $account;
|
||||
@ -219,4 +220,12 @@ class User extends ActiveRecord implements IdentityInterface
|
||||
}
|
||||
return $this->connectedAccounts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UserQuery
|
||||
*/
|
||||
public static function find()
|
||||
{
|
||||
return new UserQuery(static::class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user