pre_develop
daiao 6 years ago
parent 46e1c04e01
commit 2c980c14f5

@ -109,12 +109,12 @@ module Mobile
return uw.user if uw
end
third_party_user_id = session[:third_party_user_id]
Rails.logger.info("#########third_party_user_id: #{third_party_user_id}")
if third_party_user_id
c_user = UserSource.find_by_id(session[:third_party_user_id])
return c_user.user if c_user
end
# third_party_user_id = session[:third_party_user_id]
# Rails.logger.info("#########third_party_user_id: #{third_party_user_id}")
# if third_party_user_id
# c_user = UserSource.find_by_id(session[:third_party_user_id])
# return c_user.user if c_user
# end
token = ApiKey.where(access_token: params[:token]).first
if token && !token.expired?

@ -43,10 +43,6 @@ module Mobile
requires :accessType, type: Integer, desc: "资源类型"
end
get "source_url" do
if session[:third_party_user_id].blank?
user = User.find(params[:userId])
session[:third_party_user_id] = user.user_source.id
end
CnmoocsService.new.source_url(params)
end

@ -207,9 +207,9 @@ class ApplicationController < ActionController::Base
elsif session[:wechat_openid]
uw = UserWechat.find_by_openid(session[:wechat_openid])
user = uw.user if uw
elsif session[:third_party_user_id]
c_user = UserSource.find_by_id(session[:third_party_user_id])
user = c_user.user if c_user
elsif params[:authToken]
user = Token.find_by_value(params[:authToken]).user
session[:user_id] = user.id
end
end
if user.nil? && Setting.rest_api_enabled? && accept_api_auth?

@ -115,12 +115,13 @@ class CnmoocsService
end
def source_url(params)
user = User.find_by_id(params[:userId])
token = Token.get_or_create_permanent_login_token(user)
shixun = Shixun.find_by_id(params[:resouceId])
if shixun.blank?
return { error: -1, messages: '资源不存在' }
end
{ error: 0, messages: '成功', accessUrl: "#{Redmine::Configuration['educoder_domain']}/shixuns/#{shixun.identifier}" }
{ error: 0, messages: '成功', accessUrl: "#{Redmine::Configuration['educoder_domain']}/shixuns/#{shixun.identifier}/challenges?authToken=#{token.value}" }
end
def get_students_data params

Loading…
Cancel
Save