From 47e3e93a2f65b81ca9dccd1431089cf9f71d8111 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 27 May 2015 19:37:46 +0800 Subject: [PATCH] =?UTF-8?q?cookies=20=E5=88=A0=E9=99=A4=E4=B9=9F=E9=9C=80?= =?UTF-8?q?=E8=A6=81domain?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 2 +- app/controllers/application_controller.rb | 2 +- config/configuration.yml | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 75be302cd..dc1cceb87 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -336,7 +336,7 @@ class AccountController < ApplicationController :expires => 1.month.from_now, :path => (Redmine::Configuration['autologin_cookie_path'] || '/'), :secure => (Redmine::Configuration['autologin_cookie_secure'] ? true : false), - :domain => '.trustie.net', + :domain => Redmine::Configuration['cookie_domain'], :httponly => true } cookies[autologin_cookie_name] = cookie_options diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0dc86fb01..02b2f0d1d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -199,7 +199,7 @@ class ApplicationController < ActionController::Base # Logs out current user def logout_user if User.current.logged? - cookies.delete(autologin_cookie_name) + cookies.delete(autologin_cookie_name, domain: Redmine::Configuration['cookie_domain']) # Token.delete_all(["user_id = ? AND action = ?", User.current.id, 'autologin']) self.logged_user = nil end diff --git a/config/configuration.yml b/config/configuration.yml index 87a54a976..45e307157 100644 --- a/config/configuration.yml +++ b/config/configuration.yml @@ -90,6 +90,7 @@ default: user_name: "huang.jingquan@163.com" password: 'xinhu1ji2qu366' + cookie_domain: ".trustie.net" # Absolute path to the directory where attachments are stored. # The default is the 'files' directory in your Redmine instance. # Your Redmine instance needs to have write permission on this