Archived
1
0
Fork 0

app/library/Auth.php: switch $_session_key to a constant.

This commit is contained in:
Henrik Hautakoski 2018-08-17 16:56:05 +02:00
parent ca7a3675f7
commit 15a9009828
No known key found for this signature in database
GPG key ID: 839F3A7EAFAEAFAA

View file

@ -9,10 +9,7 @@ use App\Model\Data\User,
class Auth extends Component class Auth extends Component
{ {
/** const SESSION_KEY = 'auth';
* @var string
*/
protected $_session_key = 'auth';
/** /**
* Login using email/user + password combination. * Login using email/user + password combination.
@ -92,7 +89,7 @@ class Auth extends Component
*/ */
public function setIdentity($identity) public function setIdentity($identity)
{ {
$this->session->set($this->_session_key, $identity); $this->session->set(self::SESSION_KEY, $identity);
return $this; return $this;
} }
@ -101,7 +98,7 @@ class Auth extends Component
*/ */
public function getIdentity() public function getIdentity()
{ {
$id = $this->session->get($this->_session_key); $id = $this->session->get(self::SESSION_KEY);
if ($id !== null) { if ($id !== null) {
return User::findFirst($id); return User::findFirst($id);
@ -116,7 +113,7 @@ class Auth extends Component
{ {
if ($this->hasIdentity()) { if ($this->hasIdentity()) {
$id = $this->session->get($this->_session_key); $id = $this->session->get(self::SESSION_KEY);
return User::findFirst($id); return User::findFirst($id);
} }
@ -128,8 +125,6 @@ class Auth extends Component
return $this->getIdentity() !== NULL; return $this->getIdentity() !== NULL;
} }
/** /**
* Clears the identity information. * Clears the identity information.
* *
@ -137,7 +132,7 @@ class Auth extends Component
*/ */
public function clearIdentity() public function clearIdentity()
{ {
$this->session->remove($this->_session_key); $this->session->remove(self::SESSION_KEY);
return $this; return $this;
} }
} }