Class: Wechat::WechatController
- Inherits:
-
BaseController
- Object
- BaseController
- BaseController
- Wechat::WechatController
- Defined in:
- app/controllers/wechat/wechat_controller.rb
Instance Method Summary collapse
Instance Method Details
#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 |
#login ⇒ Object
20 21 22 23 24 25 26 |
# File 'app/controllers/wechat/wechat_controller.rb', line 20 def login @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 |