Skip to content

Commit

Permalink
Merge pull request #702 from bakaphp/hotfix-social-login-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
kaioken authored Jun 30, 2021
2 parents bd4ad40 + e0720ad commit dd380c4
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Api/Controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
use Canvas\Notifications\ResetPassword;
use Canvas\Notifications\Signup;
use Canvas\Notifications\UpdateEmail;
use Canvas\Validation;
use Exception;
use Phalcon\Http\Response;
use Phalcon\Validation\Validator\Email;

class AuthController extends BaseController
{
Expand Down Expand Up @@ -330,13 +332,14 @@ public function loginBySocial() : Response

$this->request->validate([
'social_id' => 'required',
'email' => 'required|email',
'provider' => 'required',
]);

$source = Sources::findFirstOrFail([
'title = ?0 and is_deleted = 0',
'bind' => [$request['provider']]
'bind' => [
$request['provider']
]
]);

if ($source->isApple()) {
Expand All @@ -345,6 +348,15 @@ public function loginBySocial() : Response
$request['email'] = $appleUserInfo->email;
}

$emailValidation = new Validation();
$emailValidation->add(
'email',
new Email([
'The email is required'
])
);
$emailValidation->validate($request);

return $this->response(
$this->providerLogin($source, $request['social_id'], $request)
);
Expand Down

0 comments on commit dd380c4

Please sign in to comment.