app/controllers/AuthController.php: add registerAction()
This commit is contained in:
parent
a337ccd4fa
commit
7b2f53e4dc
1 changed files with 33 additions and 2 deletions
|
|
@ -2,9 +2,12 @@
|
||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Controller\ControllerBase;
|
use App\Controller\ControllerBase,
|
||||||
|
App\Model\Data\User,
|
||||||
|
App\Form\Login as LoginForm,
|
||||||
|
App\Form\Registration as RegistrationForm;
|
||||||
|
|
||||||
use App\Form\Login as LoginForm;
|
use Httpcb\OAuth\UserData\UserDataInterface;
|
||||||
|
|
||||||
class AuthController extends ControllerBase
|
class AuthController extends ControllerBase
|
||||||
{
|
{
|
||||||
|
|
@ -106,6 +109,34 @@ class AuthController extends ControllerBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function registerAction()
|
||||||
|
{
|
||||||
|
$data = $this->session->get('auth:register:data');
|
||||||
|
if (!($data instanceof UserDataInterface)) {
|
||||||
|
$this->response->redirect('/');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$form = new RegistrationForm($data);
|
||||||
|
|
||||||
|
if ($this->request->isPost()) {
|
||||||
|
$user = new User();
|
||||||
|
$formData = $this->request->getPost();
|
||||||
|
if ($form->isValid($formData, $user) && $user->save()) {
|
||||||
|
$this->auth->systemLogin($user);
|
||||||
|
$this->flash->success('User successfully created. Now add your first callback!');
|
||||||
|
$this->response->redirect('/callback/new');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$form->setEntity($formData);
|
||||||
|
} else {
|
||||||
|
$form->isValid($data->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->view->provider = $data->getProvider();
|
||||||
|
$this->view->form = $form;
|
||||||
|
}
|
||||||
|
|
||||||
public function logoutAction()
|
public function logoutAction()
|
||||||
{
|
{
|
||||||
$this->auth->clearIdentity();
|
$this->auth->clearIdentity();
|
||||||
|
|
|
||||||
Reference in a new issue