From 82fb8690427fc45e460e6c64c98796c50c30431e Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Wed, 15 Aug 2018 22:07:19 +0200 Subject: [PATCH] app/controllers/AuthController.php: fixing registerAction() --- app/controllers/AuthController.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/app/controllers/AuthController.php b/app/controllers/AuthController.php index 51fe187..310e9de 100644 --- a/app/controllers/AuthController.php +++ b/app/controllers/AuthController.php @@ -121,16 +121,24 @@ class AuthController extends ControllerBase return; } - $form = new RegistrationForm($data); + $user = new User(); + $user->assign($data->toArray(), null, + [ 'email', 'username', 'firstname', 'lastname' ]); + + $form = new RegistrationForm($user); 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; + if ($form->isValid($formData)) { + $user->setOAuthId($data->getProvider(), $data->getId()); + if ($user->save()) { + $this->auth->systemLogin($user); + $this->flash->success('User successfully created. Now add your first callback!'); + $this->response->redirect('/callback/new'); + } else { + $this->flash->error('Could not create user'); + } } $form->setEntity($formData); } else {