Fixing API calls

This commit is contained in:
Chris Smith
2025-02-24 19:56:05 +01:00
parent 6bad9ad90d
commit 30377ad95f
3 changed files with 5 additions and 5 deletions

View File

@@ -66,12 +66,11 @@ class AuthController extends Controller
$user = User::findOne(['email' => $data['email'] ?? null]);
if (!$user || !Yii::$app->security->validatePassword($data['password'], $user->password_hash)) {
throw new UnauthorizedHttpException();
return ['error' => 'Invalid credentials'];
}
// @todo not sure if it makes sense to generate an auth key each login via the API?
$user->generateAuthKey();
$user->save();
return ['token' => $this->generateJwt($user)];
}e
}
}