Skip to content

Commit f139191

Browse files
committed
Renderer works
1 parent 9c6a496 commit f139191

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

coderd/userauth.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,8 @@ type httpError struct {
12551255
msg string
12561256
detail string
12571257
renderStaticPage bool
1258+
1259+
renderDetailMarkdown bool
12581260
}
12591261

12601262
func (e httpError) Write(rw http.ResponseWriter, r *http.Request) {
@@ -1266,6 +1268,8 @@ func (e httpError) Write(rw http.ResponseWriter, r *http.Request) {
12661268
Description: e.detail,
12671269
RetryEnabled: false,
12681270
DashboardURL: "/login",
1271+
1272+
RenderDescriptionMarkdown: e.renderDetailMarkdown,
12691273
})
12701274
return
12711275
}
@@ -1325,6 +1329,8 @@ func (api *API) oauthLogin(r *http.Request, params *oauthLoginParams) ([]*http.C
13251329
msg: "Signups are disabled",
13261330
detail: signupsDisabledText,
13271331
renderStaticPage: true,
1332+
1333+
renderDetailMarkdown: true,
13281334
}
13291335
}
13301336

site/site.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,8 @@ type ErrorPageData struct {
773773
RetryEnabled bool
774774
DashboardURL string
775775
Warnings []string
776+
777+
RenderDescriptionMarkdown bool
776778
}
777779

778780
// RenderStaticErrorPage renders the static error page. This is used by app
@@ -781,12 +783,17 @@ type ErrorPageData struct {
781783
func RenderStaticErrorPage(rw http.ResponseWriter, r *http.Request, data ErrorPageData) {
782784
type outerData struct {
783785
Error ErrorPageData
786+
787+
ErrorDescriptionHTML htmltemplate.HTML
784788
}
785789

786790
rw.Header().Set("Content-Type", "text/html; charset=utf-8")
787791
rw.WriteHeader(data.Status)
788792

789-
err := errorTemplate.Execute(rw, outerData{Error: data})
793+
err := errorTemplate.Execute(rw, outerData{
794+
Error: data,
795+
ErrorDescriptionHTML: htmltemplate.HTML(data.Description), //nolint:gosec // gosec thinks this is user-input, but it is from Coder deployment configuration.
796+
})
790797
if err != nil {
791798
httpapi.Write(r.Context(), rw, http.StatusInternalServerError, codersdk.Response{
792799
Message: "Failed to render error page: " + err.Error(),

site/static/error.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ <h1>
167167
{{- if not .Error.HideStatus }}{{ .Error.Status }} - {{end}}{{
168168
.Error.Title }}
169169
</h1>
170+
{{- if .Error.RenderDescriptionMarkdown }}
171+
{{ .ErrorDescriptionHTML }}
172+
{{ else }}
170173
<p>{{ .Error.Description }}</p>
174+
{{ end }}
171175
{{- if .Error.Warnings }}
172176
<div class="warning">
173177
<div class="warning-title">

0 commit comments

Comments
 (0)