samedi 7 janvier 2023

problems with login and authentication in laravel

i need help with my login and authentication of admin. In the database I have a table called 'admins' with coulums of 'name', 'surname', 'password' in my native language

Every time i press the login button when i try to log in i get an error:

"Undefined index: password"

where password is in English in folder:

C:\wamp\www\app\vendor\laravel\framework\src\Illuminate\Auth\EloquentUserProvider.php

and i dont know why.

My custom controller AuthController:

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Hash;
use Session;
use App\Models\Admin;
use Illuminate\Support\Facades\Auth;
class AuthController extends Controller
{
    public function index()
    {
        return view('auth.login');
    }  
      
    public function customLogin(Request $request)
    {
        $request->validate([
            'name' => 'required',
            'surname' => 'required',
            'passw' => 'required',
        ]);
   
        $credentials = $request->only('name', 'surname', 'passw');
        if (Auth::attempt($credentials)) {
            return redirect()->intended('');
        }
  
        return redirect("login")->withSuccess('Wrong input data.');
    }
    
    public function dashboard()
    {
        if(Auth::check()){
            return view('');
        }
  
        return redirect("login")->withSuccess('Wrong input data.');
    }
    
    public function signOut() {
        Session::flush();
        Auth::logout();
  
        return Redirect('');
    }
}

My route:

Auth::routes();
Route::post('/login', 'AuthController@customLogin');

I consulted with a acquaintance that specialises in web-programming and she said i should do a custom AuthController, which I did, but the problem is either still not fixed or this is a different error. And from websources i used: https://www.positronx.io/laravel-custom-authentication-login-and-registration-tutorial/



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire