1212use Application \Auth ;
1313use Application \Users ;
1414use Bluz \Application \Exception \ApplicationException ;
15+ use Bluz \Auth \AuthException ;
1516use Bluz \Auth \EntityInterface ;
1617use Bluz \Proxy \Config ;
1718use 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
0 commit comments