mikker / passwordless

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

Alternative passwordless_with options #98

Closed slucaskim closed 3 years ago

slucaskim commented 3 years ago

Hi @mikker, I'm looking to replace my use of devise with a passwordless option, and this gem is looking really promising. Thanks for the great work! I have a question about capabilities. Does this library support the use case of multiple options for matching on the authentication? What I mean is, let's say I have both email and phone attribute on my User table, and I want to let my users enter either their email OR phone to receive their magic link (via email and SMS respectively). Would this just be a matter of declaring both as passwordless_with, like:

class User < ApplicationRecord
  passwordless_with :email
  passwordless_with :phone
end

or is it more complicated than this?

Another question, how easy would it be to support a temporary code sort of auth, instead of magic links? If I were to add SMS support, I'd prefer to send a 6 digit code which then the user would enter into the app to get their session, rather than a magic link, because they might be trying to sign in on a different device than their phone.

Thanks again for this great gem!

mikker commented 3 years ago

I think you'd have a better time implementing your own custom solution for something like that. Of course, you're free to borrow as much as you want from Passwordless while building it. It's not something the gem supports right now and I think you'll be better off with something completely custom than with forcing it upon Passwordless.

You can configure your own sending mechanism with Passwordless.after_session_save. Just make it send an SMS instead of an email and it can work 😊

Good luck!

slucaskim commented 3 years ago

Thanks @mikker ! I'll look into building this myself then.