Created
April 15, 2018 20:17
-
-
Save JoseCage/a08b06d1cf626949a4cb37efc8e5190f to your computer and use it in GitHub Desktop.
Exemplo de autenticação customizada e redirecionar usuário para página anterior
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; | |
use Illuminate\Http\Request; | |
use Illuminate\Support\Facades\Auth; | |
class LoginController extends Controller | |
{ | |
/** | |
* Handle an authentication attempt. | |
* | |
* @param \Illuminate\Http\Request $request | |
* | |
* @return Response | |
*/ | |
public function authenticate(Request $request) | |
{ | |
$credentials = $request->only('email', 'password'); | |
// Verifica se os dados acima so válidos e se sim | |
// Redireciona para página anterior onde o usuário estava | |
if (Auth::attempt($credentials)) { | |
// Authentication passed... | |
return redirect()->back(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment