用户动态如果没有绑定则跳到绑定页面.

This commit is contained in:
guange 2016-05-31 19:40:54 +08:00
parent 6e44e8355c
commit 7b5a7a93f5
2 changed files with 14 additions and 12 deletions

View File

@ -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

View File

@ -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: "意见反馈"