pre_develop
daiao 6 years ago
parent d36972bec9
commit 46e1c04e01

@ -108,6 +108,14 @@ module Mobile
uw = UserWechat.find_by_openid(openid) uw = UserWechat.find_by_openid(openid)
return uw.user if uw return uw.user if uw
end 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 token = ApiKey.where(access_token: params[:token]).first
if token && !token.expired? if token && !token.expired?
return User.find(token.user_id) return User.find(token.user_id)

@ -43,10 +43,9 @@ module Mobile
requires :accessType, type: Integer, desc: "资源类型" requires :accessType, type: Integer, desc: "资源类型"
end end
get "source_url" do get "source_url" do
if session[:user_id].blank? if session[:third_party_user_id].blank?
user = User.find(params[:userId]) user = User.find(params[:userId])
return { error: -1, messages: "用户不存在,请先创建用户" } unless user.user_source session[:third_party_user_id] = user.user_source.id
session[:user_id] = user.id
end end
CnmoocsService.new.source_url(params) CnmoocsService.new.source_url(params)
end end

@ -293,7 +293,6 @@ class AccountController < ApplicationController
UserActions.create(:action_id => User.current.id, :action_type => "Logout", :user_id => User.current.id) UserActions.create(:action_id => User.current.id, :action_type => "Logout", :user_id => User.current.id)
logout_user logout_user
# 记录用户登出行为 # 记录用户登出行为
logger.info("#########logout_session: #{session}")
redirect_to home_path redirect_to home_path
end end
# display the logout form # display the logout form

@ -207,6 +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]
c_user = UserSource.find_by_id(session[:third_party_user_id])
user = c_user.user if c_user
end end
end end
if user.nil? && Setting.rest_api_enabled? && accept_api_auth? if user.nil? && Setting.rest_api_enabled? && accept_api_auth?
@ -300,6 +303,7 @@ class ApplicationController < ActionController::Base
end end
# Token.delete_all(["user_id = ? AND action = ?", User.current.id, 'autologin']) # Token.delete_all(["user_id = ? AND action = ?", User.current.id, 'autologin'])
self.logged_user = nil self.logged_user = nil
session[:third_party_user_id] = nil
end end
end end

Loading…
Cancel
Save