This commit is contained in:
Kekskurse 2019-12-25 19:38:37 +01:00
parent 8ff1dee767
commit d668b82fc6
1 changed files with 4 additions and 1 deletions

View File

@ -79,7 +79,7 @@ class UserController extends BaseController
return $response->withData(new AccessToken($token));
}
public function checkPassword(Request $request, Response $response) {
public function checkPassword(Request $request, Response $response, Client $statsd) {
//Validate Input
$this->validate($request, [
'username' => 'required',
@ -91,13 +91,16 @@ class UserController extends BaseController
//Check if a user is found
if($user == null) {
$statsd->count("pwcheck.user_wrong", 1);
throw new HTTPException("400", "Username or Password wrong");
}
if(!password_verify($request->input("password"), $user->password)) {
$statsd->count("pwcheck.password_wrong", 1);
throw new HTTPException("400", "Username or Password wrong");
}
$statsd->count("pwcheck.ok", 1);
$response->setMessage("Account ok");
return $response;