Archived
1
0
Fork 0

app/controllers/AuthController.php: in oauthAction() redirect to registration page if no user is found.

This commit is contained in:
Henrik Hautakoski 2018-08-14 22:54:13 +02:00
parent 7b2f53e4dc
commit 2529d29d80
No known key found for this signature in database
GPG key ID: 839F3A7EAFAEAFAA

View file

@ -81,17 +81,21 @@ class AuthController extends ControllerBase
else {
$result = $this->auth->loginOauth($data);
// There was an error when creating the account
if (is_array($result)) {
$msg = '';
foreach ($result as $message) {
$msg .= '<li>' . $message->getMessage() . '</li>';
if ($result === false) {
if (User::findFirstByUsernameOrEmail($data->getEmail())) {
$this->flash->error('The email address is already in use.');
$this->response->redirect('/login');
return;
}
$this->flash->message('error', "Failed to create account: <ul>{$msg}</ul>");
$this->response->redirect('/login');
} else {
$this->response->redirect('/');
$this->session->set('auth:register:data', $data);
$this->response->redirect(['for' => 'user-register']);
return;
}
// User is logged in.
$this->response->redirect('/');
}
} catch(\Exception $e) {
$this->flash->message('error', 'Failed to authenticate.');