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

Two Factor authentication issue: "undefined method `[]' for nil:NilClass" #389

Closed
jgthms opened this issue Jan 8, 2024 · 3 comments
Closed

Comments

@jgthms
Copy link

jgthms commented Jan 8, 2024

Hi and thanks for creating this library.

I am developing an app with both a main account type, and an admin one. I've succesfully followed these instructions to create both account types.

After finalising all the website features, I decided to reset the database with rake db:reset to see how the app would behave on a fresh install.

After creating a new admin account, I'm running into this error:
image

My rodauth_admin.rb configuration looks like this:
image

Did I miss a step somewhere?

@jgthms
Copy link
Author

jgthms commented Jan 8, 2024

My rodauth_app.rb configuration is:

class RodauthApp < Rodauth::Rails::App
  # primary configuration
  configure RodauthMain

  # secondary configuration
  configure RodauthAdmin, :admin

  route do |r|
    rodauth.load_memory # autologin remembered users

    r.rodauth # route rodauth requests

    # ==> Authenticating requests
    # Call `rodauth.require_account` for requests that you want to
    # require authentication for. For example:
    #
    # # authenticate /dashboard/* and /account/* requests
    # if r.path.start_with?("/dashboard") || r.path.start_with?("/account")
    #   rodauth.require_account
    # end

    # ==> Secondary configurations
    r.rodauth(:admin) # route admin rodauth requests

    if request.path.start_with?("/admin")
      rodauth(:admin).require_account
    end

    # require MFA if the user is logged in and has MFA setup
    if rodauth(:admin).uses_two_factor_authentication?
      rodauth(:admin).require_two_factor_authenticated
    end
  end
end

@jeremyevans
Copy link
Owner

You appear to be using rodauth-rails, so please open a discussion in the rodauth-rails repository: https://github.com/janko/rodauth-rails/discussions/new/choose

Only post an issue here if you can reproduce the bug in Rodauth itself (without rodauth-rails).

@jgthms
Copy link
Author

jgthms commented Jan 8, 2024

Sorry! Wrong repo indeed.

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

No branches or pull requests

2 participants