mentors

mentors Git Source Tree


Root/app/controllers/SessionController.php

<?php

class SessionController extends \BaseController
{

	public function showLogin()
	{
		if(Auth::check())
		{
			return Redirect::route('user');
		}
		
		return View::make('login');
	}

	public function doLogin()
	{
		$rules = array(
			'email'    => 'required|email', 
			'password' => 'required|alphaNum|min:3' 
		);

		$validator = Validator::make(Input::all(), $rules);

		$remember = \Input::get('remember');

		if ($validator->fails()) 
		{

			return Redirect::to('login')
				->withErrors($validator) 
				->withInput(Input::except('password'));
		} else {

			$userdata = array(
				'email' 	=> Input::get('email'),
				'password' 	=> Input::get('password')
			);

			if($remember == 'yes')
			{
				if (Auth::attempt($userdata, true)) 
				{

					return \Redirect::intended('/');

				} else {	 	

					Session::flash('message', 'You entered the wrong email or password. Try again!');
					return Redirect::to('login')->with('email', Input::get('email'));

				}
			}else
			{
				if (Auth::attempt($userdata)) 
				{

					return \Redirect::intended('/');

				} else {	 	

					Session::flash('message', 'You entered the wrong email or password. Try again!');
					return Redirect::to('login')->with('email', Input::get('email'));

				}
			}
			

		}

	}

	public function doLogout()
	{
		Auth::logout();

		return Redirect::to('/');
		
		Session::forget('user');
	}

}

Archive Download this file

Branches

Number of commits:
Page rendered in 0.10805s using 11 queries.