initial commit
This commit is contained in:
36
app/Http/Controllers/LoginController.php
Normal file
36
app/Http/Controllers/LoginController.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Http\Requests;
|
||||
use Auth;
|
||||
use Validator;
|
||||
use Redirect;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
|
||||
public function authenticate(Request $request) {
|
||||
$post = $request->all();
|
||||
$email = $post['email'];
|
||||
$password = $post['password'];
|
||||
|
||||
if (Auth::attempt(['email' => $email, 'password' => $password])) {
|
||||
|
||||
// Authentication passed...
|
||||
if (Auth::user()->role == 'admin') {
|
||||
// return $next($request);
|
||||
return redirect()->intended('admin');
|
||||
}
|
||||
return redirect('/logout');
|
||||
|
||||
|
||||
}else{
|
||||
return Redirect::back()->withErrors(array(
|
||||
'error'=>'Invalid Email Address or Password'
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user