mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 00:38:33 +02:00
refactor(auth): update WriteBlockPage function to include action text and URL
This commit is contained in:
@@ -12,11 +12,12 @@ var blockPageHTML string
|
|||||||
|
|
||||||
var blockPageTemplate = template.Must(template.New("block_page").Parse(blockPageHTML))
|
var blockPageTemplate = template.Must(template.New("block_page").Parse(blockPageHTML))
|
||||||
|
|
||||||
func WriteBlockPage(w http.ResponseWriter, status int, error string, logoutURL string) {
|
func WriteBlockPage(w http.ResponseWriter, status int, errorMessage, actionText, actionURL string) {
|
||||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||||
blockPageTemplate.Execute(w, map[string]string{
|
blockPageTemplate.Execute(w, map[string]string{
|
||||||
"StatusText": http.StatusText(status),
|
"StatusText": http.StatusText(status),
|
||||||
"Error": error,
|
"Error": errorMessage,
|
||||||
"LogoutURL": logoutURL,
|
"ActionURL": actionURL,
|
||||||
|
"ActionText": actionText,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
|
||||||
<title>Access Denied</title>
|
<title>Access Denied</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>{{.StatusText}}</h1>
|
<h1>{{.StatusText}}</h1>
|
||||||
<p>{{.Error}}</p>
|
<p>{{.Error}}</p>
|
||||||
<a href="{{.LogoutURL}}">Logout</a>
|
<a href="{{.ActionURL}}">{{.ActionText}}</a>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ func (amw *oidcMiddleware) before(w http.ResponseWriter, r *http.Request) (proce
|
|||||||
case errors.Is(err, auth.ErrMissingOAuthToken):
|
case errors.Is(err, auth.ErrMissingOAuthToken):
|
||||||
amw.auth.HandleAuth(w, r)
|
amw.auth.HandleAuth(w, r)
|
||||||
default:
|
default:
|
||||||
auth.WriteBlockPage(w, http.StatusForbidden, err.Error(), auth.OIDCLogoutPath)
|
auth.WriteBlockPage(w, http.StatusForbidden, err.Error(), "Logout", auth.OIDCLogoutPath)
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user