add login form to 403 error pages and add referrer param for user login
This commit is contained in:
parent
0450340469
commit
5e02062c26
5 changed files with 33 additions and 4 deletions
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*
|
||||
|
|
@ -41,6 +43,7 @@
|
|||
// Display statuscode and message
|
||||
$this->set('code', $httpStatusCode);
|
||||
$this->set('string', \nre\core\WebUtils::$httpStrings[$httpStatusCode]);
|
||||
$this->set('userId', $this->Auth->getUserId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,11 +117,13 @@
|
|||
public function login()
|
||||
{
|
||||
$username = '';
|
||||
$referrer = null;
|
||||
|
||||
// Log the user in
|
||||
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('login')))
|
||||
{
|
||||
$username = $this->request->getPostParam('username');
|
||||
$referrer = $this->request->getPostParam('referrer');
|
||||
$userId = $this->Users->login(
|
||||
$username,
|
||||
$this->request->getPostParam('password')
|
||||
|
|
@ -131,14 +133,20 @@
|
|||
{
|
||||
$this->Auth->setUserId($userId);
|
||||
$user = $this->Users->getUserById($userId);
|
||||
|
||||
$this->redirect($this->linker->link(array($user['url']), 1));
|
||||
|
||||
if(!empty($referrer)) {
|
||||
$this->redirect($referrer);
|
||||
}
|
||||
else {
|
||||
$this->redirect($this->linker->link(array($user['url']), 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('username', $username);
|
||||
$this->set('referrer', $referrer);
|
||||
$this->set('failed', ($this->request->getRequestMethod() == 'POST'));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue