Skip to content

Instantly share code, notes, and snippets.

@mul14
Created June 8, 2014 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mul14/7c07c69869f6dfd6b048 to your computer and use it in GitHub Desktop.
Save mul14/7c07c69869f6dfd6b048 to your computer and use it in GitHub Desktop.
Laravel - User tidak boleh login kalau sudah tiga kali salah.
<?php // app/routes.php
Route::get('login', function()
{
return View::make('login.create');
});
Route::post('login', ['before' => 'loginCounter', function()
{
$input = Input::only('username', 'password');
if (Auth::attempt($input))
return 'Login berhasil';
}]);
Route::filter('loginCounter', function()
{
if (Session::get('counter') >= 3)
return 'Tidak boleh login lagi';
$count = Session::get('counter');
Session::put('counter', $count + 1);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment