Archived
1
0
Fork 0

app/controllers/AuthController.php: in oauthAction() show flash message if account creation failed.

This commit is contained in:
Henrik Hautakoski 2018-06-08 00:12:05 +02:00
parent 03a0fa3cb7
commit 22627a811c

View file

@ -54,8 +54,19 @@ class AuthController extends ControllerBase
// NOTE: Should pass $state here also.
$data = $client->authenticate($code);
$this->auth->loginOauth($data);
$this->response->redirect('/');
$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>';
}
$this->flash->message('error', "Failed to create account: <ul>{$msg}</ul>");
$this->response->redirect('/login');
} else {
$this->response->redirect('/');
}
} catch(\Exception $e) {
$this->flash->message('error', 'Failed to authenticate.');
$this->response->redirect('/login');