verify($request->input("g-recaptcha-response")); if(!$response->isSuccess()) { throw new HTTPException(400, "Captcha validation failed"); } } //Validate Input $this->validate($request, [ 'username' => 'required', 'password' => 'required' ]); //Get User $user = User::query()->where("username", "=", $request->input("username"))->first(); //Check if a user is found if($user == null) { throw new HTTPException("400", "Username or Password wrong"); } if(!password_verify($request->input("password"), $user->password)) { throw new HTTPException("400", "Username or Password wrong"); } //Create Access Permission for WebGUI $access = AppAccess::getOrCreate($user->id, App::query()->where("name", "=", "PHP-GUI")->firstOrFail()->id); $token = \App\Models\AccessToken::createToken($access); //Save Token to Session $_SESSION["token"] = $token->token; return new AccessToken($token); } public function register(Request $request, Response $response) { } /* * Return Captcha Settings used by the public webpage bevore the user is loggedin */ public function reCAPTCHA(Response $response) { $data = []; $data["key"] = Setting::getSettingValue("recaptcha_v2_key"); $data["login"] = (bool)Setting::getSettingValue("recaptcha_v2_login"); $data["register"] = (bool)Setting::getSettingValue("recaptcha_v2_register"); return $response->withData($data); } }