Skip to content

Commit 1d67418

Browse files
committed
page oauth name correct
1 parent f8e9d24 commit 1d67418

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

mp.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ func (c *MpMgr) GetMsgHandler(req *http.Request, writer http.ResponseWriter) *br
6363
}
6464

6565
//GetPageOAuthHandler 网页授权
66-
func (c *MpMgr) GetPageOAuthHandler(req *http.Request, writer http.ResponseWriter, oAuthCallbackURL string) *bridge.PageOAuthHandler {
66+
func (c *MpMgr) GetPageOAuthHandler(req *http.Request, writer http.ResponseWriter, myURLOfPageOAuthCallback string) *bridge.PageOAuthHandler {
6767
c.Context.Request = req
6868
c.Context.Writer = writer
69-
handler := bridge.NewPageOAuthHandler(c.Context, oAuthCallbackURL)
69+
handler := bridge.NewPageOAuthHandler(c.Context, myURLOfPageOAuthCallback)
7070
return handler
7171
}
7272

mp/bridge/page_auth_handler.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ type PageOAuthHandler struct {
1515
// *wxcontext.Context
1616
*oauth.Oauth
1717

18-
oAuthCallbackURL string
19-
urlNeedOAuth string
18+
myURLOfPageOAuthCallback string
19+
myURLNeedPageOAuth string
2020

2121
openID string
2222
openIDExisting bool
@@ -27,15 +27,15 @@ type PageOAuthHandler struct {
2727
}
2828

2929
//NewPageOAuthHandler PageOAuthHandler初始化
30-
func NewPageOAuthHandler(context *wxcontext.Context, oAuthCallbackURL string) *PageOAuthHandler {
30+
func NewPageOAuthHandler(context *wxcontext.Context, myURLOfPageOAuthCallback string) *PageOAuthHandler {
3131
pa := new(PageOAuthHandler)
3232
pa.Oauth = oauth.NewOauth(context)
33-
pa.oAuthCallbackURL = oAuthCallbackURL
33+
pa.myURLOfPageOAuthCallback = myURLOfPageOAuthCallback
3434
return pa
3535
}
3636

3737
func (c *PageOAuthHandler) getCallbackURL() (u string) {
38-
return fmt.Sprintf("%s?target=%s", c.oAuthCallbackURL, url.QueryEscape(c.urlNeedOAuth))
38+
return fmt.Sprintf("%s?target=%s", c.myURLOfPageOAuthCallback, url.QueryEscape(c.myURLNeedPageOAuth))
3939
}
4040

4141
/*SetFuncCheckOpenIDExisting 设置检查OpenID在您的系统中是否已经存在
@@ -74,7 +74,7 @@ func (c *PageOAuthHandler) SetFuncAfterGetUserInfo(handler func(user.Info) bool)
7474
//Handle handler
7575
func (c *PageOAuthHandler) Handle() (err error) {
7676
code := c.Query("code")
77-
c.urlNeedOAuth = c.Query("target")
77+
c.myURLNeedPageOAuth = c.Query("target")
7878
if code != "" {
7979
var acsTkn oauth.ResAccessToken
8080
acsTkn, err = c.GetUserAccessToken(code)
@@ -87,7 +87,7 @@ func (c *PageOAuthHandler) Handle() (err error) {
8787
return
8888
}
8989
if existing {
90-
http.Redirect(c.Writer, c.Request, c.urlNeedOAuth, 302)
90+
http.Redirect(c.Writer, c.Request, c.myURLNeedPageOAuth, 302)
9191
return
9292
}
9393
//用 user模块的,没用oauth模板,可以获得更多信息
@@ -99,7 +99,7 @@ func (c *PageOAuthHandler) Handle() (err error) {
9999
if stopNow {
100100
return nil
101101
}
102-
http.Redirect(c.Writer, c.Request, c.urlNeedOAuth, 302)
102+
http.Redirect(c.Writer, c.Request, c.myURLNeedPageOAuth, 302)
103103
return nil
104104
} else {
105105
//code为空时

0 commit comments

Comments
 (0)