Method: Wechat::WechatController#auth
- Defined in:
- app/controllers/wechat/wechat_controller.rb
#auth ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/wechat/wechat_controller.rb', line 5 def auth @wechat_user = WechatUser.find_or_initialize_by(uid: params[:openid]) @wechat_user.assign_attributes params.permit(:access_token, :refresh_token, :app_id) @wechat_user.sync_user_info @wechat_user.account = current_account if current_account @wechat_user.save if @wechat_user.user login_by_wechat_user(@wechat_user) render 'auth' else render json: { oauth_user_id: @wechat_user.id } end end |