Cachet/app/controllers/AuthController.php

43 lines
939 B
PHP
Raw Normal View History

2014-11-24 15:33:36 +00:00
<?php
/**
* Logs users into their account
*/
2014-12-20 21:20:17 +00:00
class AuthController extends Controller
{
2014-12-01 08:38:26 +00:00
/**
* Shows the login view.
* @return \Illuminate\View\View
*/
2014-12-20 21:20:17 +00:00
public function showLogin()
{
return View::make('auth.login');
}
2014-11-24 15:33:36 +00:00
2014-12-01 08:38:26 +00:00
/**
* Logs the user in.
* @return \Illuminate\Http\RedirectResponse
*/
2014-12-20 21:20:17 +00:00
public function postLogin()
{
if (Auth::attempt(Input::only(['email', 'password']))) {
return Redirect::intended('dashboard');
} else {
2014-12-01 08:34:37 +00:00
return Redirect::back()
->withInput(Input::except('password'))
->with('error', 'Invalid email or password');
}
}
2014-11-24 15:33:36 +00:00
2014-12-01 08:38:26 +00:00
/**
* Logs the user out, deleting their session etc.
* @return \Illuminate\Http\RedirectResponse
*/
2014-12-20 21:20:17 +00:00
public function logoutAction()
{
Auth::logout();
2014-12-20 21:20:17 +00:00
return Redirect::to('/');
}
}