SHARE
TWEET

Untitled

a guest Jun 29th, 2011 52 Never
  1. <?php defined('SYSPATH') OR die('No direct access allowed.');
  2. /**
  3.  * Default Kohana controller. This controller should NOT be used in production.
  4.  * It is for demonstration purposes only!
  5.  *
  6.  * @package    Core
  7.  * @author     Kohana Team
  8.  * @copyright  (c) 2007-2008 Kohana Team
  9.  * @license    http://kohanaphp.com/license.html
  10.  */
  11. class User_Controller extends Template_Controller {
  12.  
  13.         // Disable this controller when Kohana is set to production mode.
  14.         // See http://docs.kohanaphp.com/installation/deployment for more details.
  15.         const ALLOW_PRODUCTION = FALSE;
  16.  
  17.         // Set the name of the template to use
  18.         public $template = 'template';
  19.  
  20.  
  21.         public function login() {
  22.  
  23.                 $this->template->title = 'Logowanie :: photowall.me';
  24.  
  25.                 //Check if already logged in
  26.                 if (Auth::instance()->logged_in('login')) {
  27.                         url::redirect('index');
  28.                 } else if (Auth::instance()->logged_in()) {
  29.                         url::redirect('accessdenied'); //User hasn't confirmed account yet
  30.                 }
  31.          
  32.                 //Initialize template and form fields
  33.                 $this->template->content = new View('user/login');
  34.                 $this->template->content->username = '';
  35.                 $view->template->content->password = '';
  36.          
  37.                 //Attempt login if form was submitted
  38.                 if ($post = $this->input->post()) {
  39.                         if (ORM::factory('user')->login($post)) {
  40.                                 url::redirect('panel/projects');
  41.                         } else {
  42.                                 die(print_r($post->errors()));
  43.                                 $this->template->content->username = $post['username']; //Redisplay username (but not password) when form is redisplayed.
  44.                                 $view->template->content->message = in_array('required', $post->errors()) ? 'Username and password are required.' : 'Invalid username and/or password.';
  45.                         }
  46.                 }
  47.          
  48.                 //Display login form
  49.                 #$view->render(TRUE);
  50.         }
  51.  
  52. }
RAW Paste Data
Top