设计:登录用户并重定向到子域

时间:2017-01-03 08:16:16

标签: ruby-on-rails redirect devise multi-tenant apartment-gem

我正在使用公寓设计 gem来进行多租户和身份验证。

我在根域网址(//.... setSupportActionBar(toolbar); setToolbarIcon(); //... private void setToolbarIcon() { Drawable logo = getResources().getDrawable(R.drawable.app_logo); if (toolbar != null) { toolbar.setLogo(logo); toolbar.setTitle(null); }} )中有一个sign_up页面,我从中获取了用户的子域详细信息。

成功保存记录并重定向到新子域(example.com)后,我需要sign_in用户。

公寓架构:

  

帐户=>所有模式的通用(公共)

     

用户=>为每个模式单独创建(私有)

这个RegistrationController

sub.example.com

以上代码成功重定向到新的子域,但是,虽然我在重定向之前在用户中签名,但它并没有在用户中签名。

任何人都可以帮助我将用户重定向为class Users::RegistrationsController < Devise::RegistrationsController ... ... def create ActiveRecord::Base.transaction do @account = Account.new(account_params) if @account.valid? # Create & switch to the new tenant Apartment::Tenant.create(@account.subdomain) Apartment::Tenant.switch!(@account.subdomain) @account.save sign_in(:user, @account.user) redirect_to root_url(subdomain: "#{Apartment::Tenant.current}") else render :action => 'new' end end end ... ... protected def account_params params.require(:account).permit(:name, :subdomain, user_attributes: [:first_name, :last_name, :email, :password, :password_confirmation]) end end 到新的子域。

谢谢..

1 个答案:

答案 0 :(得分:0)

最后,通过在:domain => :all :domain => 'example.com'中添加session_store或rootdomain config.session_store :cookie_store, :key => '_domain_session', :domain => :all 选项解决了这个问题。

<强>配置/初始化/ session_store.rb

config.session_store :cookie_store, :key => '_domain_session', :domain => 'example.com'

(或)

#!/bin/bash
host='ftp.xxxx.com'
USER='xxxx'
PASSWD='xxxx'

ftp -n -v $host << EOF
ascii
user $USER $PASSWD
prompt
mls /TEST/file.txt test.txt
quit
EOF

if [[ $? -eq 0 ]] 
        then
            echo "The File file.txt Exists";
        else 
            echo "The File file.txt dons not Exist";
fi
相关问题