Example #1
0
 /**
  * Show Auth View
  * 
  * @return  void
  */
 public function authorizeTask()
 {
     //create request & response objects
     $request = OAuth2\Request::createFromGlobals();
     $response = new OAuth2\Response();
     // get the application model (by client ID)
     $model = new Models\Api\Application();
     $this->view->application = $model->loadByClientId($request->query('client_id'));
     // force query string redirect param
     if (!$request->query('redirect_uri')) {
         throw new Exception('No redirect URI', 400);
     }
     // validate the authorize request
     if (!$this->server->validateAuthorizeRequest($request, $response)) {
         throw new Exception($response->getParameter('error_description'), 400);
     }
     // make sure were logged in
     if (User::isGuest()) {
         // redirect to login
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($_SERVER['REQUEST_URI'])), Lang::txt('You must be logged in to authorize %s', $this->view->application->get('name')), 'warning');
     }
     // display authorize form
     $this->view->display();
 }