From 7b5a7a93f535555d72b83a475a7228f62a182cee Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 31 May 2016 19:40:54 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=8A=A8=E6=80=81=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E6=B2=A1=E6=9C=89=E7=BB=91=E5=AE=9A=E5=88=99=E8=B7=B3?= =?UTF-8?q?=E5=88=B0=E7=BB=91=E5=AE=9A=E9=A1=B5=E9=9D=A2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 24 +++++++++++++----------- config/menu.yml | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) 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: "意见反馈"