app/library/Auth.php: switch $_session_key to a constant.
This commit is contained in:
parent
ca7a3675f7
commit
15a9009828
1 changed files with 5 additions and 10 deletions
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue