Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1.     public function login() {
  2.  
  3.         $this->template->title = 'Logowanie :: photowall.me';
  4.  
  5.         //Check if already logged in
  6.         if (Auth::instance()->logged_in('login')) {
  7.             url::redirect('index');
  8.         } else if (Auth::instance()->logged_in()) {
  9.             url::redirect('accessdenied'); //User hasn't confirmed account yet
  10.         }
  11.      
  12.         //Initialize template and form fields
  13.         $this->template->content = new View('user/login');
  14.         $this->template->content->username = '';
  15.         $view->template->content->password = '';
  16.      
  17.         //Attempt login if form was submitted
  18.         if ($post = $this->input->post()) {
  19.             if (ORM::factory('user')->login($post)) {
  20.                 url::redirect('panel/projects');
  21.             } else {
  22.                 die(print_r($post->errors()));
  23.                 $this->template->content->username = $post['username']; //Redisplay username (but not password) when form is redisplayed.
  24.                 $view->template->content->message = in_array('required', $post->errors()) ? 'Username and password are required.' : 'Invalid username and/or password.';
  25.             }
  26.         }
  27.      
  28.         //Display login form
  29.         #$view->render(TRUE);
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement