Created
January 15, 2015 11:01
-
-
Save lozadaOmr/968ded3d0ae87b0231b8 to your computer and use it in GitHub Desktop.
Laravel 4.2 CMSController.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class CMSController extends BaseController { | |
| /** | |
| * Display the login page. | |
| * GET /cms | |
| * | |
| * @return Response | |
| */ | |
| public function login() | |
| { | |
| return View::make('cms.login'); | |
| } | |
| /** | |
| * Accepts the post request for login | |
| * of user in CMS | |
| * | |
| */ | |
| public function userLogin() | |
| { | |
| $user_credentials['email'] = Input::get('email'); | |
| $user_credentials['password'] = Input::get('password'); | |
| //sets the remember_me variable | |
| if (Input::has('remember')) | |
| { | |
| $remember_me = true; | |
| } | |
| else | |
| { | |
| $remember_me = false; | |
| } | |
| if ($errors = User::loginIsInvalid($user_credentials)) | |
| { | |
| return Redirect::route('cms.login')->withInput()->withErrors($errors); | |
| } | |
| if (Auth::attempt(array( | |
| 'email' => $user_credentials['email'], | |
| 'password' => $user_credentials['password']), $remember_me)) | |
| { | |
| return Redirect::route('cms.home'); | |
| } | |
| } | |
| /** | |
| * Accepts the post request for logout | |
| * of user in CMS | |
| * | |
| */ | |
| public function userLogout() | |
| { | |
| Session::clear(); | |
| Auth::logout(); | |
| return Redirect::route('cms.login'); | |
| } | |
| /** | |
| * Directs user to home page | |
| * | |
| */ | |
| public function home() | |
| { | |
| return View::make('cms.home'); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment