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

Handling Admin User #23

Closed
j-manu opened this issue Jan 4, 2021 · 1 comment
Closed

Handling Admin User #23

j-manu opened this issue Jan 4, 2021 · 1 comment

Comments

@j-manu
Copy link

j-manu commented Jan 4, 2021

In devise when I want to have admin users, I create a separate model AdminUser.
How do I handle that here?

@janko
Copy link
Owner

janko commented Jan 5, 2021

Assuming that you want special authentication behaviour for admin users, you would typically create a separate Rodauth configuration with a diffferent route prefix:

class RodauthApp < Rodauth::Rails::App
  # main users
  configure do
    # ...
  end

  # admin users
  configure(:admin) do
    enable ... # admin features
    prefix "/admin"
  end

  route do |r|
    # ...
    r.rodauth
    r.on("admin") { r.rodauth(:admin) } # route admin authentication requests
    # ...
  end
end

You should be able to reuse the main accounts table and other account_* tables for storing admin users. However, if you need things like separate email uniqueness validation, you can choose a different table:

configure(:admin) do
  # ...
  accounts_table :admin_accounts
  password_hash_table :admin_account_password_hashes
  # ... and so on ...
end

@janko janko closed this as completed Jan 5, 2021
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