Class: Wechat::WechatController

Inherits:
BaseController show all
Defined in:
app/controllers/wechat/wechat_controller.rb

Instance Method Summary collapse

Instance Method Details

#authObject



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.
  @wechat_user. =  if 
  @wechat_user.save

  if @wechat_user.user
    (@wechat_user)
    render 'auth'
  else
    render json: { oauth_user_id: @wechat_user.id }
  end
end

#loginObject



20
21
22
23
24
25
26
# File 'app/controllers/wechat/wechat_controller.rb', line 20

def 
  @scene = Scene.find_or_initialize_by(appid: current_wechat_app.appid, match_value: "session_#{session.id}")
  @scene.expire_seconds ||= 600 # 默认600秒有效
  @scene.organ_id = current_wechat_app.organ_id
  @scene.save
  @scene
end