Skip to content
Advertisement

Laravel 5.6 – User not getting authenticated

I have looked for days, but my user never gets authenticated when using the auth middleware.

We don’t use the standard laravel way, but using the standard auth middleware to block access to a route group. (in this example the dashboards)

The data is correct as it doesnt give any error message, but the user itself never gets authenticated. I’ve been stuck at it since wednesday and I hope any of you can finally fix this problem.

There isn’t really any specific code, but my (try to) login user always get directed to the unauthenticated method. (which leads back to another route of mine, index)

Important database columns for login are called ‘username’ and ‘password’ (the standard name laravel uses)

So, please, if any of you can help, I’d be hella grateful!

Inside LeerlingController (where login function is)

JavaScript

Inside Leerling Model (the part to make it authenticatable)

JavaScript

Method that keeps happening while logging in a valid user as no fail message comes up Which is located in AppExceptionsHandler.php

JavaScript

The dashboard routes protected by auth middleware

JavaScript

Auth.php

JavaScript

Advertisement

Answer

Laravel models default to id as a column name in Models. If you use anything different that id, you should set a protected property $primaryKey with the name of your table’s primary key. Eg:

JavaScript

Documentation: Eloquent: #Primary Keys

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement