initial commit
This commit is contained in:
commit
e869a1cab4
107 changed files with 9029 additions and 0 deletions
52
app/controllers/AuthController.php
Normal file
52
app/controllers/AuthController.php
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
class AuthController extends ControllerBase
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$form = new Form\Login();
|
||||
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->getPost();
|
||||
if ($form->isValid($data)) {
|
||||
|
||||
$email = $form->getValue('Email');
|
||||
$passwd = $form->getValue('Password');
|
||||
|
||||
// Perform login
|
||||
if ($this->auth->login($email, $passwd)) {
|
||||
$this->response->redirect('/');
|
||||
} else {
|
||||
$this->flash->message('error', "Invalid credentials");
|
||||
}
|
||||
} else {
|
||||
$msg = '<ul>';
|
||||
|
||||
foreach($form->getMessages() as $message) {
|
||||
$msg .= '<li><strong>' . $message->getField() . '</strong> '. $message->getMessage() . '</li>';
|
||||
}
|
||||
|
||||
$msg .= '</ul>';
|
||||
$this->flash->message('error', $msg);
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->form = $form;
|
||||
}
|
||||
|
||||
public function oauthAction()
|
||||
{
|
||||
$response = $this->oauth->perform();
|
||||
|
||||
if (is_array($response)) {
|
||||
$this->auth->loginOauth($response['auth']);
|
||||
}
|
||||
$this->response->redirect('/');
|
||||
}
|
||||
|
||||
public function logoutAction()
|
||||
{
|
||||
$this->auth->clearIdentity();
|
||||
$this->response->redirect('/');
|
||||
}
|
||||
}
|
||||
Reference in a new issue