samedi 7 janvier 2023

problems with login and authentication in laravel

i need help with my login and authentication of users.

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

"Undefined index: password"

in

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('');
    }
}

name, surname is in my native language and (passw) symbolises that the password is also in my native language.

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/



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/Lru2jkJ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire