Skip to content

Commit

Permalink
Merge pull request #3 from bluzphp/develop
Browse files Browse the repository at this point in the history
Updated requirements
  • Loading branch information
Anton authored Sep 26, 2017
2 parents 349c11e + 290c040 commit c0c1808
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
21 changes: 9 additions & 12 deletions application/models/Auth/AuthProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Application\Auth;
use Application\Users;
use Bluz\Application\Exception\ApplicationException;
use Bluz\Auth\AuthException;
use Bluz\Auth\EntityInterface;
use Bluz\Proxy\Config;
use Bluz\Proxy\Messages;
Expand Down Expand Up @@ -48,7 +49,7 @@ class AuthProvider implements AuthInterface
public function __construct($providerName)
{
if (!in_array(ucfirst($providerName), $this->getAvailableProviders())) {
throw new ApplicationException(sprintf('Provider % is not defined
throw new ApplicationException(__('Provider `%s` is not defined
in configuration file', ucfirst($providerName)));
}
$this->providerName = ucfirst($providerName);
Expand Down Expand Up @@ -117,7 +118,7 @@ public function getAuthAdapter()
$this->authAdapter = $this->getHybridauth()->authenticate($this->providerName);

if (!$this->authAdapter->isUserConnected()) {
throw new \Exception('Cannot connect to current provider !');
throw new AuthException('Cannot connect to current provider!');
}
}

Expand Down Expand Up @@ -148,7 +149,7 @@ public function registration($data, $user)
$row->tokenType = Auth\Table::TYPE_ACCESS;
$row->save();

Messages::addNotice(sprintf('Your account was linked to %s successfully !', $this->providerName));
Messages::addNotice('Your account was linked to %s successfully !', $this->providerName);
Response::redirectTo('users', 'profile', ['id' => $user->id]);
}

Expand All @@ -160,15 +161,11 @@ public function authProcess()
$this->authAdapter = $this->getAuthAdapter();
$profile = $this->getProfile();

/**
* @var Auth\Table $authTable
*/
$authTable = Auth\Table::getInstance();
$auth = $authTable->getAuthRow(strtolower($this->providerName), $profile->identifier);
$auth = Auth\Table::getAuthRow(strtolower($this->providerName), $profile->identifier);

if ($this->identity) {
if ($auth) {
Messages::addNotice(sprintf('You have already linked to %s', $this->providerName));
Messages::addNotice('You have already linked to %s', $this->providerName);
Response::redirectTo('users', 'profile', ['id' => $this->identity->id]);
} else {
$user = Users\Table::findRow($this->identity->id);
Expand All @@ -179,7 +176,7 @@ public function authProcess()
if ($auth) {
$this->alreadyRegisteredLogic($auth);
} else {
Messages::addError(sprintf('First you need to be linked to %s', $this->providerName));
Messages::addError('First you need to be linked to %s', $this->providerName);
Response::redirectTo('users', 'signin');
}
}
Expand Down Expand Up @@ -209,11 +206,11 @@ public function alreadyRegisteredLogic($auth)
{
$user = Users\Table::findRow($auth->userId);

if ($user->status != Users\Table::STATUS_ACTIVE) {
if ($user->status !== Users\Table::STATUS_ACTIVE) {
Messages::addError('User is not active');
}

$user->tryLogin();
Table::tryLogin($user);
Response::redirectTo('index', 'index');
}

Expand Down
2 changes: 1 addition & 1 deletion application/modules/auth/controllers/endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Application;

/**
* @return \closure
* @return void
*/
return function () {
\Hybrid_Endpoint::process();
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"license": "MIT",
"description": "bluz auth module",
"require": {
"bluzphp/composer-plugin": "~2.0"
"bluzphp/composer-plugin": "~2.1"
}
}

0 comments on commit c0c1808

Please sign in to comment.