1
I have a project that consists of an administration.
What I’m doing is logging in, I already created the table and entered a password user in the mode Hash of Laravel.
I have the system that apparently works, what happens is that when I try to log in the always wrong data error and I’m putting in the right data username and password that I created in the table.
You can help me figure out the problem?
Controller
namespace App\Http\Controllers\admin;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\User;
use DB;
use Auth;
use Redirect;
use Hash;
use Illuminate\Support\Facades\Input;
class LoginController extends Controller
{
public function showLogin ()
{
if (Auth::check()) {
return Redirect::to('/admin');
}
return view('admin/login');
}
public function postLogin()
{
$data = [
'username' => Input::get('username'),
'passwd' => Input::get('password')
];
if (Auth::attempt($data)) {
return Redirect::intended('admin');
}
return Redirect::back()->with('error_message', 'Dados Incorrectos')->withInput();
}
public function logOut()
{
Auth::logout();
return Redirect::to('admin/login')->with('error_message', 'Logged out correctly');
}
}
Caro Cesar should be by email field and not by username as described in documentation, expensive that there are other means of authentication, for example, by the class instance
User, but it’s not your case.– novic
Ready. I edited the answer is the second option.
– novic