From 03a0fa3cb723f876b18969a11f030781e18be2f3 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Fri, 8 Jun 2018 00:07:42 +0200 Subject: [PATCH] app/library/Auth.php: make loginOauth() return validation messages if User::save() fails. --- app/library/Auth.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/library/Auth.php b/app/library/Auth.php index 9f1a841..75c622b 100644 --- a/app/library/Auth.php +++ b/app/library/Auth.php @@ -43,7 +43,8 @@ class Auth extends Component /** * Login using OAuth * - * @param UserDataInterface $auth + * @param UserDataInterface $data + * @return bool|\Phalcon\Mvc\Model\MessageInterface[] */ public function loginOauth(UserDataInterface $data) { @@ -52,13 +53,18 @@ class Auth extends Component if (!$user) { // Did not find any user. create him. $user = User::createFromOAuthData($data); - $user->save(); + + if ($user->save() === false) { + return $user->getMessages(); + } } $this->setIdentity($user->getId()); $this->_eventsManager->fire('auth:onLogin', $this, "OAuth {$data->getProvider()}"); + + return true; } /**