fix: form post template

This commit is contained in:
Lakhan Samani 2022-10-18 23:03:52 +05:30
parent eaa10ec5bc
commit 7c2693b086
2 changed files with 7 additions and 7 deletions

View File

@ -86,7 +86,7 @@ func AuthorizeHandler() gin.HandlerFunc {
loginError := map[string]interface{}{ loginError := map[string]interface{}{
"type": "authorization_response", "type": "authorization_response",
"response": map[string]string{ "response": map[string]interface{}{
"error": "login_required", "error": "login_required",
"error_description": "Login is required", "error_description": "Login is required",
}, },
@ -113,7 +113,7 @@ func AuthorizeHandler() gin.HandlerFunc {
log.Debug("GetUserByID failed: ", err) log.Debug("GetUserByID failed: ", err)
handleResponse(gc, responseMode, loginURL, redirectURI, map[string]interface{}{ handleResponse(gc, responseMode, loginURL, redirectURI, map[string]interface{}{
"type": "authorization_response", "type": "authorization_response",
"response": map[string]string{ "response": map[string]interface{}{
"error": "signup_required", "error": "signup_required",
"error_description": "Sign up required", "error_description": "Sign up required",
}, },
@ -181,7 +181,7 @@ func AuthorizeHandler() gin.HandlerFunc {
handleResponse(gc, responseMode, loginURL, redirectURI, map[string]interface{}{ handleResponse(gc, responseMode, loginURL, redirectURI, map[string]interface{}{
"type": "authorization_response", "type": "authorization_response",
"response": map[string]string{ "response": map[string]interface{}{
"code": code, "code": code,
"state": state, "state": state,
}, },
@ -287,7 +287,7 @@ func validateAuthorizeRequest(responseType, responseMode, clientID, state, codeC
func handleResponse(gc *gin.Context, responseMode, loginURI, redirectURI string, data map[string]interface{}, httpStatusCode int) { func handleResponse(gc *gin.Context, responseMode, loginURI, redirectURI string, data map[string]interface{}, httpStatusCode int) {
isAuthenticationRequired := false isAuthenticationRequired := false
if _, ok := data["response"].(map[string]string)["error"]; ok { if _, ok := data["response"].(map[string]interface{})["error"]; ok {
isAuthenticationRequired = true isAuthenticationRequired = true
} }
@ -308,7 +308,7 @@ func handleResponse(gc *gin.Context, responseMode, loginURI, redirectURI string,
case constants.ResponseModeFormPost: case constants.ResponseModeFormPost:
gc.HTML(httpStatusCode, authorizeFormPostTemplate, gin.H{ gc.HTML(httpStatusCode, authorizeFormPostTemplate, gin.H{
"target_origin": redirectURI, "target_origin": redirectURI,
"authorization_response": data, "authorization_response": data["response"],
}) })
return return
} }

View File

@ -4,9 +4,9 @@
<title>Authorization Response</title> <title>Authorization Response</title>
</head> </head>
<body onload="document.forms['authorize_form_post'].submit()"> <body onload="document.forms['authorize_form_post'].submit()">
<form action={{.target_origin}} name="authorize_form_post"> <form action="{{.target_origin}}" name="authorize_form_post" method="POST">
{{ range $key, $val := .authorization_response }} {{ range $key, $val := .authorization_response }}
<input type="hidden" key={{$key}} value={{$val}} name={{$key}} id={{$key}} /> <input type="hidden" key="{{$key}}" value="{{$val}}" name="{{$key}}" id="{{$key}}" />
{{ end }} {{ end }}
</form> </form>
</body> </body>