commit
3ab11b91ca
@ -1,11 +1,32 @@
|
||||
class Oauth::WechatController < Oauth::BaseController
|
||||
def create
|
||||
user, new_user = Oauth::CreateOrFindWechatAccountService.call(current_user ,params)
|
||||
# user, new_user = Oauth::CreateOrFindWechatAccountService.call(current_user ,params)
|
||||
|
||||
successful_authentication(user) if !new_user
|
||||
begin
|
||||
code = params['code'].to_s.strip
|
||||
tip_exception("code不能为空") if code.blank?
|
||||
new_user = false
|
||||
|
||||
render_ok(new_user: new_user)
|
||||
rescue Oauth::CreateOrFindWechatAccountService::Error => ex
|
||||
render_error(ex.message)
|
||||
result = WechatOauth::Service.access_token(code)
|
||||
result = WechatOauth::Service.user_info(result['access_token'], result['openid'])
|
||||
|
||||
# 存在该用户
|
||||
open_user = OpenUsers::Wechat.find_by(uid: result['unionid'])
|
||||
if open_user.present? && open_user.user.present?
|
||||
successful_authentication(open_user.user)
|
||||
else
|
||||
if current_user.blank? || !current_user.logged?
|
||||
new_user = true
|
||||
set_session_openid(result['openid'])
|
||||
set_session_unionid(result['unionid'])
|
||||
else
|
||||
OpenUsers::Wechat.create!(user: current_user, uid: result['unionid'])
|
||||
end
|
||||
end
|
||||
|
||||
render_ok(new_user: new_user)
|
||||
rescue WechatOauth::Error => ex
|
||||
render_error(ex.message)
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
class SyncSubjectdsMobile < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
SubDisciplineContainer.find_each do |sc|
|
||||
subject.find(sc.container_id).update_column(:show_mobile => true)
|
||||
end
|
||||
end
|
||||
end
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue