Fuel\Core\FuelException [ Error ]: Controller_Admin::action_login() or the controller after() method must return a Response object.
<?php /** * The Admin Controller. * * Controller of the whole admin * * @package app * @extends Controller */ class Controller_Admin extends Controller_Template { public $template = 'admin/_layout'; public $title = 'Administration de QMCE'; public $data = array(); /** * Before : Check authentification * * @access public * @return Response */ public function before() { parent::before(); //Check authentification $auth = Auth::instance(); if (Request::active()->action != 'login') { if(Auth::check()) { if(!$auth->member('100')) { Session::set_flash('information', '<b>Information :</b> Ce formulaire vous deconnectera de votre compte actuel.'); Response::redirect('admin/login'); } } else { Response::redirect('admin/login'); } } if (Request::active()->action == 'login') { if(Auth::check()) { if($auth->member('100')) { $auth->logout(); Session::set_flash('informationLogin', '<b>Information :</b> Vous etiez deja connecte en tant qu\'admin, vous avez ete deconnecte.'); } else { $auth->logout(); Session::set_flash('informationLogin', '<b>Information :</b> Vous etiez deja connecte en tant que non admin, vous avez ete deconnecte.'); } } } if(Auth::check() AND $auth->member('100')) { $this->template->set_global('loggedIn', $auth->get_screen_name()); } else { $this->template->set_global('loggedIn', false); } } public function after($response) { parent::after($response); //Set views infos $this->template->title = $this->title; $chemin = Uri::string(); if(Request::active()->action == 'index') //If it's the index { $segments = Uri::segments(); if(end($segments) != 'index') { $chemin .= '/index'; } } $this->template->content = View::forge($chemin, $this->data); return $response; } /** * Index page : Show panel * * @access public * @return Response */ public function action_index() { $this->title .= ' > Accueil'; } /** * Login method * * @access public * @return Response */ public function action_login() { $this->title .= ' > Login'; if(Input::post()) //If it is submitted { $auth = Auth::instance(); if($auth->login()) //Based on POST name, no need to give ID to it. If login success { if($auth->member('100')) //If it is a developer { Response::redirect('admin'); } else //Else, not enough rights { Session::set_flash('error', '<b>Erreur :</b> Ce compte ne dispose pas des droits necessaires.'); } } else //If login fails { Session::set_flash('error', '<b>Erreur :</b> Les identifiants sont incorrects.'); } } } public function action_logout() { $auth = Auth::instance(); $auth->logout(); //No need to check if user is connected, because else the before method handle and redirect to login Response::redirect('admin/login'); } }I know that the before() method is not pretty coded but I'll correct it, I promise ! Thank you in advance. PS : I am sorry for my english, I am french and I am (only) 15 years old, so I am learning but I don't really practice in a real environment.
It looks like you're new here. If you want to get involved, click one of these buttons!