mikker / passwordless

🗝 Authentication for your Rails app without the icky-ness of passwords
MIT License
1.27k stars 87 forks source link

Instant sign up #63

Closed dankimio closed 5 years ago

dankimio commented 5 years ago

First of all, thanks for the gem, great work!

Some apps do not require separate registration and combine sign in and sign up forms. If there's no user with such email, the app creates a user with that email and sends a confirmation link.

How can this flow be implemented with passwordless?

mikker commented 5 years ago

Thank you 😊

You could do that by stitching together half of the Registering users example and the contents of create in SessionsController.

if (user = User.find_by(email: params[:email])
  # send email
else
  # create user, send email/sign in
end

I won't write an example for you but do update this if you make something work!

dankimio commented 4 years ago

What would be the correct procedure for overriding SessionsController without copying the whole class?

dankimio commented 4 years ago

Okay, so I implemented fetch_resource_for_passwordless with find_or_create_by(email: email) in my class and it basically works as instant sign-up.