@@ -137,30 +137,51 @@ func AuthorizeHandler() gin.HandlerFunc {
137137
138138 // in case, response type is code and user is already logged in send the code and state
139139 // and cookie session will already be rolled over and set
140- if responseMode == constants .ResponseModeFormPost {
141- gc .HTML (http .StatusOK , authorizeFormPostTemplate , gin.H {
142- "target_origin" : redirectURI ,
143- "authorization_response" : map [string ]interface {}{
144- "type" : "authorization_response" ,
145- "response" : map [string ]string {
146- "code" : code ,
147- "state" : state ,
148- },
149- },
150- })
151- } else {
152- gc .HTML (http .StatusOK , authorizeWebMessageTemplate , gin.H {
153- "target_origin" : redirectURI ,
154- "authorization_response" : map [string ]interface {}{
155- "type" : "authorization_response" ,
156- "response" : map [string ]string {
157- "code" : code ,
158- "state" : state ,
159- },
160- },
161- })
140+ // if responseMode == constants.ResponseModeFormPost {
141+ // gc.HTML(http.StatusOK, authorizeFormPostTemplate, gin.H{
142+ // "target_origin": redirectURI,
143+ // "authorization_response": map[string]interface{}{
144+ // "type": "authorization_response",
145+ // "response": map[string]string{
146+ // "code": code,
147+ // "state": state,
148+ // },
149+ // },
150+ // })
151+ // } else {
152+ // gc.HTML(http.StatusOK, authorizeWebMessageTemplate, gin.H{
153+ // "target_origin": redirectURI,
154+ // "authorization_response": map[string]interface{}{
155+ // "type": "authorization_response",
156+ // "response": map[string]string{
157+ // "code": code,
158+ // "state": state,
159+ // },
160+ // },
161+ // })
162+ // }
163+
164+ params := "code=" + code + "&state=" + state
165+
166+ if responseMode == constants .ResponseModeQuery {
167+ if strings .Contains (redirectURI , "?" ) {
168+ redirectURI = redirectURI + "&" + params
169+ } else {
170+ redirectURI = redirectURI + "?" + params
171+ }
172+ } else if responseMode == constants .ResponseModeFragment {
173+ if strings .Contains (redirectURI , "#" ) {
174+ redirectURI = redirectURI + "&" + params
175+ } else {
176+ redirectURI = redirectURI + "#" + params
177+ }
162178 }
163179
180+ handleResponse (gc , responseMode , loginURL , redirectURI , map [string ]interface {}{
181+ "code" : code ,
182+ "state" : state ,
183+ }, http .StatusOK )
184+
164185 return
165186 }
166187
0 commit comments