Skip to content

Commit c7b8e77

Browse files
author
dengbinbox
committed
fix: URL concatenation for redirection
1 parent 9fc3dd9 commit c7b8e77

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

internal/handler/router.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ func (s *Server) SetupRouter(r *gin.Engine) {
5050
webOauthServer.GET("bind/account", s.bindAccount)
5151
webOauthServer.GET("bind/account/callback", s.bindAccountCallback)
5252
webOauthServer.GET("userinfo", s.userInfoHandler)
53-
webOauthServer.GET("login", s.webLoginHandler)
53+
webOauthServer.GET("login", s.webLoginHandler) // web login entry point and redirect to custom service
5454
webOauthServer.GET("login/callback", s.webLoginCallbackHandler)
55-
webOauthServer.GET("login/callback/:service", s.webLoginCallbackHandler)
55+
webOauthServer.GET("login/callback/:service", s.webLoginCallbackHandler) // with service param, custom redirect
5656
webOauthServer.GET("invite-code", s.getUserInviteCodeHandler)
5757
}
5858
r.POST("/oidc-auth/api/v1/send/sms", s.SMSHandler)

internal/handler/web_handler.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@ func (s *Server) webLoginHandler(c *gin.Context) {
3737

3838
// Use inviterCode as state parameter
3939
state := inviterCode
40-
authURL := providerInstance.GetAuthURL(state, s.BaseURL+constants.WebLoginCallbackURI)
40+
var redirectURL = ""
4141
if redirectService != "" {
42-
authURL = fmt.Sprintf("%s/%s", authURL, redirectService)
42+
redirectURL = fmt.Sprintf("%s/%s", s.BaseURL+constants.WebLoginCallbackURI, redirectService)
43+
} else {
44+
redirectURL = s.BaseURL + constants.WebLoginCallbackURI
4345
}
46+
authURL := providerInstance.GetAuthURL(state, redirectURL)
4447
response.JSONSuccess(c, "", map[string]interface{}{
4548
"state": state,
4649
"inviter_code": inviterCode,

0 commit comments

Comments
 (0)