Cachet/app/controllers/AuthController.php

38 lines
926 B
PHP
Raw Normal View History

2014-11-24 15:33:36 +00:00
<?php
/**
* Logs users into their account
*/
class AuthController extends Controller {
2014-12-01 08:38:26 +00:00
/**
* Shows the login view.
* @return \Illuminate\View\View
*/
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
*/
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
*/
public function logoutAction() {
Auth::logout();
return Redirect::to('/');
}
}