This commit is contained in:
Kekskurse 2019-12-25 19:38:37 +01:00
parent 8ff1dee767
commit d668b82fc6

View file

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