Commit 7bb4c62f authored by Vassilis Kanellopoulos's avatar Vassilis Kanellopoulos
Browse files

validate when loging from database; phpCS

parent 02beb04b
......@@ -49,11 +49,18 @@ class RedBeanPHP extends AbstractAdapter
$events = $this->events;
$events('trigger', 'authenticate', $this);
$user = R::findOne('user', 'mail = ? AND authentication_source = ?', [
$this->getIdentity(),
'DB',
$email = filter_var($this->getIdentity(), FILTER_VALIDATE_EMAIL);
$isValidCredential = filter_var(strlen(trim($this->getCredential())), FILTER_VALIDATE_INT, [
'options'=> ['min_range' => 8],
]);
if (!$email || !$isValidCredential) {
return new Result(Result::FAILURE_CREDENTIAL_INVALID, null, [self::$failMessage]);
}
$user = R::findOne('user', 'mail = ? AND authentication_source = ?', [$email, 'DB']);
if (!$user) {
return new Result(Result::FAILURE_IDENTITY_NOT_FOUND, null, [self::$failMessage]);
}
......
......@@ -39,8 +39,9 @@ class FetchUnit
$responseData = json_decode($response->getBody()->getContents(), true);
if (!isset($responseData['data']) || empty($responseData['data'])) {
return null;
return;
}
return $responseData['data'][0];
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment