How to send magic link after user registrated
Is there any way to send magic link after user registered like sign_in @user for security?
Did I make myself clear? Let me explain more.
I would like to make the flow, from signup to signin, like slack. The flow like below.
- Input email for signup.
- check email and click.
Could you let me know how to do this?
I think it will work if I could use module Passwordless properly...but I didn't.
As far as I know, this gem has 2 flows.
First: It is a pain in input twice.
- Input email for signup.
- Input email for signin.
- check email and click.
Second: It is not good for security because the email might not valid.
- Input email for signup and signin.(using
sign_in @user)
Something like this...
# registrations_controller.rb
include Passwordless::ControllerHelpers
def create
user = User.new(email: params[:email])
if user.save
pwless_session = build_passwordless_session(user)
pwless_session.save!
YourOwnRegistrationsMailer.signup(token: pwless_session.token).deliver_now
# ... redirect back or whatever
end
end
Thank you for your help!! I did it like below!
def create
@user = User.new(user_params)
respond_to do |format|
if @user.save
pwless_session = build_passwordless_session(@user)
pwless_session.save!
RegistrationMailer.with(token: pwless_session.token, user: @user).welcome_email.deliver_now
# ... redirect back or whatever
end
end
I want you to add this way at README.md if you can. Anyway, please enjoy a cup of coffee, maybe for one year!!
This is wrong
I've deleted the message due to wrong content - some local issue on my machine.
I'm not sure that's right. save! calls callbacks: https://guides.rubyonrails.org/active_record_callbacks.html#running-callbacks
You are right, but this is a case for my small test project using your gem. I'll create a new issue with all information.