passwordless icon indicating copy to clipboard operation
passwordless copied to clipboard

require email presence in SIGN_IN

Open yshmarov opened this issue 2 years ago • 6 comments

if the "send magic link" form is submitted without an email, there will be an SMTP error. Screenshot 2022-11-08 at 13 23 35

this is because we do not guard against submitting a nil email.

yshmarov avatar Nov 08 '22 12:11 yshmarov

Hey, i'd like to contribute on this issue if possible. Is it still ongoing? I see the first step has already been merged.

fchatterji avatar Feb 06 '23 17:02 fchatterji

Please go ahead 😊 PRs welcome

mikker avatar Feb 07 '23 21:02 mikker

@mikker Ok, I'm not really sure the second step is needed. Usually you would put the validation in the model, and the controller would render the error just fine. But here, the user of the gem creates the user model.

We could add a validation in the controller, render :new and use flash messages to add the error. But it seems overly complex. I think the user of the gem should be responsible for validating that he doesn´t allow empty emails on his own backend.

What do you think?

fchatterji avatar Feb 08 '23 17:02 fchatterji

hey @fchatterji ! Having just frontend presence validation is not enough. This way, a user can input an invalid email, successfully submit the form, and get Net::SMTPSyntaxError in passwordless/sessions # create.

I think we can add some validation in find_authenticable to check if email satisfies URI::MailTo::EMAIL_REGEXP...

yshmarov avatar Feb 09 '23 09:02 yshmarov

Hey @yshmarov, ok thanks, I see what you mean, here's my PR: https://github.com/mikker/passwordless/pull/134

fchatterji avatar Feb 09 '23 14:02 fchatterji