jeremyevans / rodauth

Ruby's Most Advanced Authentication Framework
http://rodauth.jeremyevans.net
MIT License
1.67k stars 95 forks source link

Extract `account_table_ds` private method #268

Closed janko closed 1 year ago

janko commented 1 year ago

As discussed in https://github.com/jeremyevans/rodauth/discussions/267, this is useful when sharing database tables between different Rodauth configurations, and wanting to store the account type alongside account records, as it allows filtering retrieved accounts in a single place.

Example usage:

plugin :rodauth, name: :admin do
  enable :create_account, :login

  before_create_account do
    account[:type] = "admin"
  end

  auth_class_eval do
    def account_table_ds
      super.where(type: "admin")
    end
  end
end
jeremyevans commented 1 year ago

Thanks for the patch. This looks good. I'll try to test and merge today, but it might slip to next week.