0

i'm new to Laravel and haven't worked out every detail of how it works though I'm looking for some help to implement an authentication workflow where a user can register without setting a password. Once the user clicks to verify their email they will be shown the setup password page where they can enter a nominated password for that account.

Currently I'm using the default authentication workflow from Laravel, minus the password fields and have setup a middleware to check if password has been set and if not redirect to the setup password page. Instead of doing this it's redirecting me to the login page.

I can't find any help or articles out there relating to this workflow, if anyone can help or provide redirections that would be much appreciated.

theduck
  • 2,589
  • 13
  • 17
  • 23
  • 5
    Please post the current code from the RegisterController and of your middleware. It will be easier for the community to help you. – Lucien Dubois Nov 06 '19 at 16:40

1 Answers1

0

You can still use the default authentication login of laravel, you only need to tweak it a little.

Add a is_active field on your Users table then put this on your LoginController:

protected function credentials(Request $request)
{        
   return ['email' => $request->email, 'password' => $request->password, 'is_active' => 1];
}

What will happen:

Upon registration, user cannot login because of the added condition above --> the is_active field.

Upon registration, send an email with a link. After the user clicks the link on that email, update the user's is_active field so that he can able to login.

It may not be what exactly what you want, but it achieved the same logic. User elected his own password and validated his email.

kapitan
  • 2,008
  • 3
  • 20
  • 26