From 6ecea79dc3f50ea778b995363f7a2bf78cbc5b3c Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 29 May 2019 17:28:00 +0800 Subject: [PATCH] 1 --- app/api/mobile/apis/cnmooc.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/api/mobile/apis/cnmooc.rb b/app/api/mobile/apis/cnmooc.rb index 7546fd58..720ac26b 100644 --- a/app/api/mobile/apis/cnmooc.rb +++ b/app/api/mobile/apis/cnmooc.rb @@ -43,9 +43,11 @@ module Mobile requires :accessType, type: Integer, desc: "资源类型" end get "source_url" do - user_source = UserSource.find_by_user_id(params[:userId]) - return {error: -1, messages: "用户不存在,请先创建用户"} if user_source.blank? - self.logged_user = user_source.user + if session[:user_id].blank? + user = User.find(params[:userId]) + return { error: -1, messages: "用户不存在,请先创建用户" } unless user.user_source + session[:user_id] = user.user_source.id + end CnmoocsService.new.source_url(params) end