Skip to content

Commit c0c1808

Browse files
author
Anton
authored
Merge pull request #3 from bluzphp/develop
Updated requirements
2 parents 349c11e + 290c040 commit c0c1808

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

application/models/Auth/AuthProvider.php

+9-12
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Application\Auth;
1313
use Application\Users;
1414
use Bluz\Application\Exception\ApplicationException;
15+
use Bluz\Auth\AuthException;
1516
use Bluz\Auth\EntityInterface;
1617
use Bluz\Proxy\Config;
1718
use Bluz\Proxy\Messages;
@@ -48,7 +49,7 @@ class AuthProvider implements AuthInterface
4849
public function __construct($providerName)
4950
{
5051
if (!in_array(ucfirst($providerName), $this->getAvailableProviders())) {
51-
throw new ApplicationException(sprintf('Provider % is not defined
52+
throw new ApplicationException(__('Provider `%s` is not defined
5253
in configuration file', ucfirst($providerName)));
5354
}
5455
$this->providerName = ucfirst($providerName);
@@ -117,7 +118,7 @@ public function getAuthAdapter()
117118
$this->authAdapter = $this->getHybridauth()->authenticate($this->providerName);
118119

119120
if (!$this->authAdapter->isUserConnected()) {
120-
throw new \Exception('Cannot connect to current provider !');
121+
throw new AuthException('Cannot connect to current provider!');
121122
}
122123
}
123124

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

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

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

163-
/**
164-
* @var Auth\Table $authTable
165-
*/
166-
$authTable = Auth\Table::getInstance();
167-
$auth = $authTable->getAuthRow(strtolower($this->providerName), $profile->identifier);
164+
$auth = Auth\Table::getAuthRow(strtolower($this->providerName), $profile->identifier);
168165

169166
if ($this->identity) {
170167
if ($auth) {
171-
Messages::addNotice(sprintf('You have already linked to %s', $this->providerName));
168+
Messages::addNotice('You have already linked to %s', $this->providerName);
172169
Response::redirectTo('users', 'profile', ['id' => $this->identity->id]);
173170
} else {
174171
$user = Users\Table::findRow($this->identity->id);
@@ -179,7 +176,7 @@ public function authProcess()
179176
if ($auth) {
180177
$this->alreadyRegisteredLogic($auth);
181178
} else {
182-
Messages::addError(sprintf('First you need to be linked to %s', $this->providerName));
179+
Messages::addError('First you need to be linked to %s', $this->providerName);
183180
Response::redirectTo('users', 'signin');
184181
}
185182
}
@@ -209,11 +206,11 @@ public function alreadyRegisteredLogic($auth)
209206
{
210207
$user = Users\Table::findRow($auth->userId);
211208

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

216-
$user->tryLogin();
213+
Table::tryLogin($user);
217214
Response::redirectTo('index', 'index');
218215
}
219216

application/modules/auth/controllers/endpoint.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace Application;
99

1010
/**
11-
* @return \closure
11+
* @return void
1212
*/
1313
return function () {
1414
\Hybrid_Endpoint::process();

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"license": "MIT",
55
"description": "bluz auth module",
66
"require": {
7-
"bluzphp/composer-plugin": "~2.0"
7+
"bluzphp/composer-plugin": "~2.1"
88
}
99
}

0 commit comments

Comments
 (0)