Merge remote-tracking branch 'origin/develop' into develop

chromesetting
杨树明 5 years ago
commit 53d5053a2d

@ -291,14 +291,10 @@ 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
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}"]
uid_logger("user setup start: session[:user_id] is #{session[:user_id]}")
if session[:user_id]
# existing session
(User.active.find(session[:"#{re_subdomain}"]) rescue nil)
(User.active.find(session[:user_id]) rescue nil)
elsif autologin_user = try_to_autologin
autologin_user
elsif params[:format] == 'atom' && params[:key] && request.get? && accept_rss_auth?

@ -62,21 +62,18 @@ module LoginHelper
end
def start_user_session(user)
re_subdomain = "#{request.subdomain.split('.').first}_user_id"
# re_subdomain = "#{request.subdomain.split('.').first}_user_id"
# session[:"#{request.subdomain}_user_id"] = user.id
# Rails.logger.info("domain_user_id session is: 3333332222111#{session[:"#{request.subdomain}_user_id"]}")
# Rails.logger.info("user_id session is: 3333332222111#{session[:"#{request.subdomain}_user_id"]}")
#
# # if current_laboratory.main_site?
# # session[:user_id] = user.id
# # else
# # session[:"#{request.subdomain}_user_id"] = user.id
# # end
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[:user_id] = user.id
session[:ctime] = Time.now.utc.to_i
session[:atime] = Time.now.utc.to_i
end

@ -103,7 +103,7 @@ class HackUserLastestCodesController < ApplicationController
if exec_mode == "submit"
@hack.hack_sets.map{|set| {input: set.input, output: set.output, caseId: set.id}}
else
{input: params[:input]}
[{input: params[:input]}]
end
testCases = Base64.urlsafe_encode64(test_sets.to_json)
#codeFileContent = Base64.urlsafe_encode64(@my_hack.code)

@ -27,7 +27,7 @@ class HacksController < ApplicationController
# 筛选过滤与排序
params_filter_or_order
# 我解决的编程题数
user_codes = HackUserLastestCode.joins(:hack).mine(current_user).passed
user_codes = HackUserLastestCode.joins(:hack).mine_hack(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

@ -9,6 +9,7 @@ class HackUserLastestCode < ApplicationRecord
has_many :hack_user_codes, dependent: :destroy
has_one :hack_user_debug
scope :mine, ->(author_id){ find_by(user_id: author_id) }
scope :mine_hack, ->(author_id){ where(user_id: author_id) }
scope :passed, -> {where(status: 1)}
end

@ -44,7 +44,9 @@ Rails.application.routes.draw do
get :start
get :result
end
resources :comments
resources :comments do
end
end
resources :hack_user_lastest_codes, path: :myproblems, param: :identifier do

Loading…
Cancel
Save