That may work. You could also store the email/username column normally, but do not make it unique. Instead, have a composite unique constraint on (tenant_id, email). Then override account_from_login to something like:
account_from_login do |login|
ds = db[accounts_table].where(login_column=>login, :tenant_id=>request.env[:tenant_id])
ds = ds.select(*account_select) if account_select
ds = ds.where(account_status_column=>[account_unverified_status_value, account_open_status_value]) unless skip_status_checks?
ds.first
end
Here you would store the tenant_id in the rack environment, which you could do in a rack middleware, or anywhere in your Roda routing tree before dispatching to Rodauth.
Potentially we could make this easier, by adding support for something like:
account_login_filter do |login|
{login_column=>login, :tenant_id=>request.env[:tenant_id]}
end
However, I've been hesitant to add methods to Rodauth that expose too much of it's internal usage of Sequel. The current idea with Rodauth is using the existing configuration methods, you could avoid using Sequel completely. However, that approach requires you reimplement all of the low level database-type code for doing things like determining the account to use for a login by yourself (as evidenced by the account_from_login example above), so it definitely has its own issues.
Thanks,
Jeremy