Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jirisvoboda committed Jun 4, 2015
1 parent 02efbb9 commit bbc3a11
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/AuthMe.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
<?php

namespace dlds\shareit;
namespace dlds\authme;

use Yii;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use dlds\shareit\ShareItAssets;

class AuthMe extends \yii\base\Widget {
class AuthMe extends \yii\base\Component {

/**
* @var string secret key for encrypting/decrypting tokens
Expand All @@ -16,15 +13,20 @@ class AuthMe extends \yii\base\Widget {

public function loginByAccessToken($token)
{
$identity = AccessTokenHelper::getIdentity($token);
$identity = $this->getIdentity($token);

if ($identity)
{
\Yii::$app->user->login($identity);
}
}

public static function getToken(UsrIdentity $user)
public static function getIdentity($token)
{
return Yii::$app->getSecurity()->encryptByPassword(self::getTokenContent($user));
}

public static function getToken($user)
{
Yii::$app->getSecurity()->encryptByPassword(self::getTokenContent($user));
}
Expand Down
12 changes: 12 additions & 0 deletions src/interfaces/AuthIdentityInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace dlds\authme;

interface AuthIdentityInterface {

/**
* Retreives identity auth key
* @return string authorization key
*/
public function getAuthKey();
}

0 comments on commit bbc3a11

Please sign in to comment.