/** * Authenticates the given user. If successful, an instance * of the user is returned. * * @param User $user The user to authenticate * @throws InvalidLoginDataException Thrown if the user's credentials are not valid */ public function authenticate (User $user) { $result = PartKeepr::getEM() ->getRepository("de\RaumZeitLabor\PartKeepr\User\User") ->findOneBy( array( "username" => $user->getUsername(), "password" => $user->getHashedPassword() ) ); if ($result == null) { throw new InvalidLoginDataException(); } else { return $result; } }