public function authorize() { $this->getUserProvider()->verifyUser(); $request = Request::createFromGlobals(); $response = new Response(); // validate the authorize request if (!$this->server->validateAuthorizeRequest($request, $response)) { $response->send(); die; } $client_id = $request->query("client_id"); $client = $this->storage->getClientDetails($client_id); $user_id = $this->getUserProvider()->getUserId(); $is_authorized = $this->authorized($client_id, $user_id); // display an authorization form if (empty($_POST) && !$is_authorized) { $html = Tpl::authorize($client); exit($html); } // print the authorization code if the user has authorized your client $this->server->handleAuthorizeRequest($request, $response, $is_authorized, $user_id); if ($is_authorized) { // this is only here so that you get to see your code in the cURL request. Otherwise, we'd redirect back to the client $code = substr($response->getHttpHeader('Location'), strpos($response->getHttpHeader('Location'), 'code=') + 5, 40); $response->send(); //exit("SUCCESS! Authorization Code: $code"); } $response->send(); }
} } session_destroy(); $content = <<<S <div class="container"> <div class="page-header"> <h3>Autenticação </h3> </div> <form class="form-horizontal" role="form" method="post"> <div class="form-group"> <label for="login" class="col-lg-2 control-label">Login</label> <div class="col-lg-10"> <input type="text" class="form-control" id="login" name="login" placeholder="Login"> </div> </div> <div class="form-group"> <label for="password" class="col-lg-2 control-label">Password</label> <div class="col-lg-10"> <input type="password" name="password" class="form-control" id="password" placeholder="Password"> </div> </div> <div class="form-group"> <div class="col-lg-offset-2 col-lg-10"> <button type="submit" class="btn btn-primary">Sign in</button> </div> </div> </form> </div> S; echo \Paliari\Oauth2ServerFacade\Tpl::page($content);