diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index d4758283a..1e87c7b96 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -202,6 +202,19 @@ class WechatsController < ActionController::Base render 'wechats/login', layout: 'base_wechat' end + def user_activities + session[:wechat_code] = params[:code] if params[:code] + code = params[:code] || session[:wechat_code] + openid = get_openid_from_code(code) + @wechat_user = user_binded?(openid) + unless @wechat_user + redirect_to :login + return + end + + render File.join(Rails.root, "public/wechat/app.html"), layout: nil + end + private def get_openid_from_code(code) openid = session[:wechat_openid] @@ -223,18 +236,7 @@ class WechatsController < ActionController::Base uw = UserWechat.where(openid: openid).first end - def user_activities - session[:wechat_code] = params[:code] if params[:code] - code = params[:code] || session[:wechat_code] - openid = get_openid_from_code(code) - @wechat_user = user_binded?(openid) - unless @wechat_user - redirect_to :login - return - end - render File.join(Rails.root, "public/wechat/app.html"), layout: nil - end end diff --git a/config/menu.yml b/config/menu.yml index ab6ae89ac..3671ebb1b 100644 --- a/config/menu.yml +++ b/config/menu.yml @@ -2,7 +2,7 @@ button: - type: "view" name: "最新动态" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://wechat.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=123#wechat_redirect" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=http://wechat.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=123#wechat_redirect" - type: "click" name: "意见反馈"