2014-11-24 15:33:36 +00:00
|
|
|
<?php
|
|
|
|
|
2015-01-02 00:18:19 +00:00
|
|
|
namespace CachetHQ\Cachet\Http\Controllers;
|
2015-01-01 15:45:04 +00:00
|
|
|
|
|
|
|
use GrahamCampbell\Throttle\Facades\Throttle;
|
2015-01-02 12:05:50 +00:00
|
|
|
use GrahamCampbell\Binput\Facades\Binput;
|
2015-01-01 15:45:04 +00:00
|
|
|
use Illuminate\Routing\Controller;
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
use Illuminate\Support\Facades\Redirect;
|
2015-01-01 16:18:24 +00:00
|
|
|
use Illuminate\Support\Facades\Request;
|
2015-01-01 15:45:04 +00:00
|
|
|
use Illuminate\Support\Facades\View;
|
|
|
|
|
2014-11-27 16:05:00 +00:00
|
|
|
/**
|
2014-12-29 23:07:46 +00:00
|
|
|
* Logs users into their account.
|
2014-11-27 16:05:00 +00:00
|
|
|
*/
|
2014-12-20 21:20:17 +00:00
|
|
|
class AuthController extends Controller
|
|
|
|
{
|
2014-12-01 08:38:26 +00:00
|
|
|
/**
|
|
|
|
* Shows the login view.
|
2014-12-29 23:07:46 +00:00
|
|
|
*
|
2014-12-01 08:38:26 +00:00
|
|
|
* @return \Illuminate\View\View
|
|
|
|
*/
|
2014-12-20 21:20:17 +00:00
|
|
|
public function showLogin()
|
|
|
|
{
|
2014-11-27 16:05:00 +00:00
|
|
|
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.
|
2014-12-29 23:07:46 +00:00
|
|
|
*
|
2014-12-01 08:38:26 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
|
|
*/
|
2014-12-20 21:20:17 +00:00
|
|
|
public function postLogin()
|
|
|
|
{
|
2015-01-02 12:05:50 +00:00
|
|
|
if (Auth::attempt(Binput::only(['email', 'password']))) {
|
2014-11-27 16:05:00 +00:00
|
|
|
return Redirect::intended('dashboard');
|
|
|
|
}
|
2015-01-01 15:45:04 +00:00
|
|
|
|
|
|
|
Throttle::hit(Request::instance(), 10, 10);
|
|
|
|
|
|
|
|
return Redirect::back()
|
2015-01-02 12:05:50 +00:00
|
|
|
->withInput(Binput::except('password'))
|
2015-01-01 15:45:04 +00:00
|
|
|
->with('error', 'Invalid email or password');
|
2014-11-27 16:05:00 +00:00
|
|
|
}
|
2014-11-24 15:33:36 +00:00
|
|
|
|
2014-12-01 08:38:26 +00:00
|
|
|
/**
|
|
|
|
* Logs the user out, deleting their session etc.
|
2014-12-29 23:07:46 +00:00
|
|
|
*
|
2014-12-01 08:38:26 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
|
|
*/
|
2014-12-20 21:20:17 +00:00
|
|
|
public function logoutAction()
|
|
|
|
{
|
2014-11-27 16:05:00 +00:00
|
|
|
Auth::logout();
|
2014-12-20 21:20:17 +00:00
|
|
|
|
2014-11-27 16:05:00 +00:00
|
|
|
return Redirect::to('/');
|
|
|
|
}
|
2014-11-27 22:08:28 +00:00
|
|
|
}
|