diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1bc2bad7d..adef28e03 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -291,10 +291,14 @@ class ApplicationController < ActionController::Base # Returns the current user or nil if no user is logged in # and starts a session if needed def find_current_user - uid_logger("user setup start: session[:user_id] is #{session[:user_id]}") - if session[:user_id] + re_subdomain = "#{request.subdomain.split('.').first}_user_id" + + Rails.logger.info("find current_user: subdomain is #{re_subdomain} and user session is #{session[:user_id]} -- #{session[:"#{re_subdomain}"]}") + Rails.logger.info("-----------------------------") + Rails.logger.info("domain session is: #{session[:"#{request.subdomain.split('.').first}_user_id"]}") + if session[:"#{re_subdomain}"] # existing session - (User.active.find(session[:user_id]) rescue nil) + (User.active.find(session[:"#{re_subdomain}"]) rescue nil) elsif autologin_user = try_to_autologin autologin_user elsif params[:format] == 'atom' && params[:key] && request.get? && accept_rss_auth? diff --git a/app/controllers/concerns/login_helper.rb b/app/controllers/concerns/login_helper.rb index e94cf8a21..0126eb6b0 100644 --- a/app/controllers/concerns/login_helper.rb +++ b/app/controllers/concerns/login_helper.rb @@ -62,7 +62,21 @@ module LoginHelper end def start_user_session(user) - session[:user_id] = user.id + re_subdomain = "#{request.subdomain.split('.').first}_user_id" + + session[:"#{re_subdomain}"] = nil + session[:user_id] = nil + # session[:"#{re_subdomain}"] = user.id + Rails.logger.info("domain_user_id session is: 3333332222111#{session[:"#{re_subdomain}"]}") + Rails.logger.info("user_id session is: 3333332222111#{session[:user_id]}") + + # if current_laboratory.main_site? + # session[:user_id] = user.id + # else + # session[:"#{request.subdomain}_user_id"] = user.id + # end + + # session[:user_id] = user.id session[:ctime] = Time.now.utc.to_i session[:atime] = Time.now.utc.to_i end diff --git a/app/controllers/hacks_controller.rb b/app/controllers/hacks_controller.rb index 9fa8e26e3..213c38c7f 100644 --- a/app/controllers/hacks_controller.rb +++ b/app/controllers/hacks_controller.rb @@ -27,7 +27,7 @@ class HacksController < ApplicationController # 筛选过滤与排序 params_filter_or_order # 我解决的编程题数 - user_codes = HackUserLastestCode.mine(current_user).passed.joins(:hack) + user_codes = HackUserLastestCode.joins(:hack).mine(current_user).passed @simple_count = user_codes.where(hacks: {difficult: 1}).count @medium_count = user_codes.where(hacks: {difficult: 2}).count @diff_count = user_codes.where(hacks: {difficult: 3}).count diff --git a/public/react/src/modules/courses/shixunHomework/shixunreport/ConclusionEvaluation.js b/public/react/src/modules/courses/shixunHomework/shixunreport/ConclusionEvaluation.js index d5c8aa57f..5430b9e8c 100644 --- a/public/react/src/modules/courses/shixunHomework/shixunreport/ConclusionEvaluation.js +++ b/public/react/src/modules/courses/shixunHomework/shixunreport/ConclusionEvaluation.js @@ -58,7 +58,7 @@ class ConclusionEvaluation extends Component { - 分数:{record.eff_scores.eff_score}/总分:{record.eff_score_full} + 分数:{record.eff_scores.eff_score}/总分:{record.eff_scores.eff_score_full} }> {record.eff_scores.eff_score}/{record.eff_scores.eff_score_full} diff --git a/public/react/src/modules/home/shixunsHome.js b/public/react/src/modules/home/shixunsHome.js index 6971cf36c..68e37deb6 100644 --- a/public/react/src/modules/home/shixunsHome.js +++ b/public/react/src/modules/home/shixunsHome.js @@ -149,9 +149,9 @@ class ShixunsHome extends Component {