Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix :as option in passwordless_for #174

Merged
merged 6 commits into from
Nov 7, 2023
Merged

Fix :as option in passwordless_for #174

merged 6 commits into from
Nov 7, 2023

Conversation

mikker
Copy link
Owner

@mikker mikker commented Oct 21, 2023

Fixes #168

@yshmarov, @jpatters thank you for your reports. Could you try and see whether this fixes your problems? Thanks!

@mikker mikker self-assigned this Oct 21, 2023
@yshmarov
Copy link
Contributor

using gem 'passwordless', github: 'mikker/passwordless', branch: 'fix-routes',
passwordless_for :users, at: '/', as: :auth gives me the following routes:

Screenshot 2023-10-22 at 18 59 58

=> looks good

However the tests do not pass.

When callingpasswordless_sign_in(User.first) I get the following errors:

  • withpasswordless_for :users, at: '/', as: :auth
Screenshot 2023-10-22 at 19 04 38
  • with passwordless_for :users, at: '/'
Screenshot 2023-10-22 at 19 05 09

@mikker
Copy link
Owner Author

mikker commented Oct 23, 2023

Hmm, that looks weird? Do you use the bundled mailer? It shouldn't use send in this branch: https://github.com/mikker/passwordless/blob/fix-routes/app/mailers/passwordless/mailer.rb#L15-L24

@mikker
Copy link
Owner Author

mikker commented Oct 31, 2023

Did you get a chance to look more into this, @yshmarov

@jpatters
Copy link

I will try to make some time to test this later this week.

@yshmarov
Copy link
Contributor

yshmarov commented Oct 31, 2023

Hmm, that looks weird? Do you use the bundled mailer? It shouldn't use send in this branch: https://github.com/mikker/passwordless/blob/fix-routes/app/mailers/passwordless/mailer.rb#L15-L24

It is failing on this line:
https://github.com/mikker/passwordless/blob/master/lib/passwordless/test_helpers.rb#L11

with this change it works for me:

      def passwordless_sign_in(resource)
        session = Passwordless::Session.create!(authenticatable: resource)
        # magic_link = Passwordless::Engine.routes.url_helpers.send(
        #   :"confirm_#{session.authenticatable_type.tableize}_sign_in_url",
        #   session,
        #   session.token
        # )
        magic_link = url_for(
          {
            controller: "passwordless/sessions",
            action: "confirm",
            id: session.id,
            token: session.token,
            authenticatable: session.authenticatable_type.singularize.downcase,
            resource: session.authenticatable_type.tableize
          }
        )

@mikker
Copy link
Owner Author

mikker commented Nov 7, 2023

Of course, I didn't realise it was the test helpers. Fixed now, thanks!

@mikker mikker merged commit 7b84234 into master Nov 7, 2023
3 checks passed
@mikker mikker deleted the fix-routes branch November 7, 2023 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

troubles upgrading to 1.0.0
3 participants