Skip to content

Commit

Permalink
Merge pull request #46 from deanblackborough/main
Browse files Browse the repository at this point in the history
Auth update
  • Loading branch information
deanblackborough authored Jan 30, 2023
2 parents 5b48b07 + 6f006ff commit 28a26b9
Show file tree
Hide file tree
Showing 4 changed files with 813 additions and 668 deletions.
17 changes: 16 additions & 1 deletion app/Auth/Guard/Api/Guard.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ public function validate(array $credentials = [], bool $remember_me = false): bo
{
$api = new Service($this->request->cookie($this->config['cookie_bearer']));

if (array_key_exists('email', $credentials) === false || $credentials['email'] === null) {
$this->errors['email']['errors'] = [
'You need to provide your email address'
];
}
if (array_key_exists('password', $credentials) === false || $credentials['password'] === null) {
$this->errors['password']['errors'] = [
'You need to provide your password'
];
}

if (count($this->errors) > 0) {
return false;
}

$response = $api->authSignIn(
$credentials['email'],
$credentials['password']
Expand Down Expand Up @@ -102,7 +117,7 @@ public function validate(array $credentials = [], bool $remember_me = false): bo
}

if ($response['status'] === 422) {
$this->errors = $response['content']['fields'];
$this->errors = $response['fields'];
return false;
}

Expand Down
Loading

0 comments on commit 28a26b9

Please sign in to comment.