This commit is contained in:
Bastian Allgeier
2019-01-15 11:43:30 +01:00
parent 8070893b64
commit f596ff5c4c
5 changed files with 46 additions and 10 deletions

View File

@@ -35,12 +35,16 @@ return [
$long = $this->requestBody('long');
$password = $this->requestBody('password');
if ($user = $this->kirby()->auth()->login($email, $password, $long)) {
return [
'code' => 200,
'status' => 'ok',
'user' => $this->resolve($user)->view('auth')->toArray()
];
try {
if ($user = $this->kirby()->auth()->login($email, $password, $long)) {
return [
'code' => 200,
'status' => 'ok',
'user' => $this->resolve($user)->view('auth')->toArray()
];
}
} catch (Throwable $e) {
// catch any kind of login error
}
throw new InvalidArgumentException('Invalid email or password');