mardi 1 mai 2018

Laravel 5.6 manual Authentication

When I started a new project I used make:auth() to automatically build the scaffolding for logging in, registering etc, which was pretty cool.

I no longer need this as I want to manually use Auth::login($user); after carrying out my own checks. At this time I use a post route to my app and check the data in the post request to validate against a pre-populated users table.

When this happens, I manually log in the user.

When a user is not logged in the application tries to redirect to a login page but obviously, this no longer exists.

I am having trouble finding what defines this behaviour, could I remove it and catch unauthenticated users myself, or is this a bad idea?

My overall aim is this:

  • The user sends a POST request to the app either from an internal server or a small Office 365 login page.
  • In this POST request there should be an email address, I use this as a check against the users table.
  • If I find them I use Auth to log the user in so that I have access to the authenticated user.

I intend to and have half finished re-writing a controller method that performs this check but I am stumped because I can't see where the Auth class is defining the redirection to log in.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire