我正在使用Devise进行身份验证的多功能应用程序。子域的使用对于此构建至关重要。
目前我的设置包括强制用户记住'他们的子域名,以便他们可以登录。
路线
constraints(SubdomainPresent) do
root 'users#index', as: :subdomain_root
resources :users
resources :accounts
end
devise_for :users
我希望实现的内容与我的用户首次注册时发生的情况非常类似,一旦保存,它们将被重定向到其子域以进行登录(url结构反映了这一点)subdomain.example.com
帐户控制器
if @account.valid?
Apartment::Tenant.create(@account.subdomain)
Apartment::Tenant.switch(@account.subdomain)
@account.save
format.html { redirect_to new_user_session_url(subdomain: @account.subdomain), notice: 'Account was successfully created.' }
我想拥有它,以便我的用户可以从网站上的任何位置登录,非子域名位置,并将其重定向到正确的dashbaord和子域名网址结构
答案 0 :(得分:1)
您可以覆盖 after_sign_up_path_for 方法并使用以下内容:
def after_sign_up_path_for(resource)
edit_user_registration_url(:subdomain => resource.subdomain)
end