Commit 6f0d7120 by mingyuan

add debug info

parent 6cc6f8eb
...@@ -10,19 +10,7 @@ module Dingtalk ...@@ -10,19 +10,7 @@ module Dingtalk
def login def login
@dingtalk_user = @app.generate_user(params[:code]) @dingtalk_user = @app.generate_user(params[:code])
if @oauth_user.account.nil? && current_account @dingtalk_user.save
@oauth_user.account = current_account
end
@oauth_user.save
if @oauth_user.user
login_by_oauth_user(@oauth_user)
Com::SessionChannel.broadcast_to(params[:state], auth_token: current_authorized_token.token)
else
url_options = {}
url_options.merge! params.except(:controller, :action, :id, :business, :namespace, :code, :state).permit!
url_options.merge! host: URI(session[:return_to]).host if session[:return_to]
end
end end
def create def create
......
...@@ -29,11 +29,12 @@ module Dingtalk ...@@ -29,11 +29,12 @@ module Dingtalk
} }
r = HTTPX.post "https://api.dingtalk.com/v1.0/oauth2/userAccessToken", body: h.to_json r = HTTPX.post "https://api.dingtalk.com/v1.0/oauth2/userAccessToken", body: h.to_json
result = JSON.parse(r.body.to_s) result = JSON.parse(r.body.to_s)
logger.debug result
#binding.break #binding.break
wechat_user = wechat_users.find_or_initialize_by(uid: result['openid']) # wechat_user = wechat_users.find_or_initialize_by(uid: result['openid'])
wechat_user.assign_attributes result.slice('access_token', 'refresh_token', 'unionid') # wechat_user.assign_attributes result.slice('access_token', 'refresh_token', 'unionid')
wechat_user.expires_at = Time.current + result['expires_in'].to_i # wechat_user.expires_at = Time.current + result['expires_in'].to_i
wechat_user # wechat_user
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment