Created
January 28, 2017 10:12
-
-
Save yooouuri/8cf51ab702e4460b7657390f8da88b77 to your computer and use it in GitHub Desktop.
This file contains 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 | |
namespace App\Http\Controllers\admin; | |
use App\User; | |
use Illuminate\Http\Request; | |
use App\Http\Controllers\Controller; | |
use Illuminate\Support\Facades\Auth; | |
class UserController extends Controller | |
{ | |
/** | |
* @param Request $request | |
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector | |
*/ | |
public function login(Request $request) | |
{ | |
$this->validate($request, [ | |
'email' => 'required|email|exists:users,email', | |
'password' => 'required', | |
]); | |
if ($user = Auth::attempt([ | |
'email' => $request->email, | |
'password' => $request->password | |
])) { | |
/** @var $user User */ | |
if ($user->isAdmin()) { | |
return redirect() | |
->route('admin.dashboard'); | |
} | |
} | |
return redirect('/admin/login'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great