pre_develop
daiao 6 years ago
parent 46e1c04e01
commit 2c980c14f5

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

@ -43,10 +43,6 @@ module Mobile
requires :accessType, type: Integer, desc: "资源类型" requires :accessType, type: Integer, desc: "资源类型"
end end
get "source_url" do 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) CnmoocsService.new.source_url(params)
end end

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

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

Loading…
Cancel
Save