Skip to content

Commit a79040e

Browse files
fix: csrf and clean up web
1 parent 31e9834 commit a79040e

11 files changed

+92
-50
lines changed

web/components/format_date.templ

+4
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ import "github.com/ItsNotGoodName/smtpbridge/web/meta"
66
templ FormatDate(m meta.Meta, t time.Time) {
77
<sl-format-date month="numeric" day="numeric" year="numeric" hour="numeric" minute="numeric" hour-format={ m.TimeHourFormat } date={ t.Format(time.RFC3339) }></sl-format-date>
88
}
9+
10+
templ FormatDateString(m meta.Meta, t string) {
11+
<sl-format-date month="numeric" day="numeric" year="numeric" hour="numeric" minute="numeric" hour-format={ m.TimeHourFormat } date={ t }></sl-format-date>
12+
}

web/components/format_date_templ.go

+40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/components/rule_form.templ

+6
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ templ RuleFormUpdate(props RuleFormUpdateProps) {
108108
}
109109
</fieldset>
110110
<button disabled?={ props.Rule.Internal } type="submit" class="btn btn-primary btn-block">Update Rule</button>
111+
if props.Rule.Internal {
112+
<div class="alert alert-warning">
113+
<svg xmlns="http://www.w3.org/2000/svg" class="stroke-current shrink-0 h-6 w-6" fill="none" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" /></svg>
114+
<span>Cannot be edited because it is an internal rule.</span>
115+
</div>
116+
}
111117
if props.Flash != nil {
112118
{! props.Flash }
113119
}

web/components/rule_form_templ.go

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/http/router.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func NewRouter(ct pages.Controller, app core.App, fileFS fs.FS, csrfSecret []byt
2323
r.Use(middleware.RealIP)
2424
r.Use(middleware.Logger)
2525
r.Use(middleware.Recoverer)
26-
r.Use(csrf.Protect(csrfSecret, csrf.Secure(false)))
26+
r.Use(csrf.Protect(csrfSecret, csrf.Secure(false), csrf.Path("/")))
2727

2828
mountWebFS(r, web.FS)
2929

web/pages/attachment.templ

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ templ attachmentListView(m meta.Meta, props attachmentListViewProps) {
2525
</div>
2626
<div class="flex flex-col gap-4 p-4">
2727
<div class="join flex items-center justify-end">
28-
<button class="btn btn-sm btn-info join-item" hx-post={ routes.AttachmentTrim().URLString() }>
28+
<button class="btn btn-sm btn-info join-item tooltip-left tooltip" data-tip="delete orphan attachments" hx-post={ routes.AttachmentTrim().URLString() }>
2929
@icons.Recycle("w-5 h-5")
3030
</button>
3131
</div>

web/pages/attachment_templ.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/pages/envelope.templ

+3-8
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,9 @@ templ envelopeListView(m meta.Meta, props envelopeListViewProps) {
180180
}
181181
</td>
182182
<th class="w-0 whitespace-nowrap">
183-
<div class="join flex items-center">
184-
<a href={ routes.Envelope(env.Message.ID).URL() } class="btn btn-primary btn-xs join-item">
185-
@icons.Eye("h-4 w-4")
186-
</a>
187-
<button class="btn btn-error btn-xs join-item" hx-delete={ routes.Envelope(env.Message.ID).URLString() } hx-target="closest tr" hx-confirm="Are you sure you wish to delete this envelope?" >
188-
@icons.Trash("h-4 w-4")
189-
</button>
190-
</div>
183+
<button class="btn btn-error btn-xs join-item" hx-delete={ routes.Envelope(env.Message.ID).URLString() } hx-target="closest tr" hx-confirm="Are you sure you wish to delete this envelope?" >
184+
@icons.Trash("h-4 w-4")
185+
</button>
191186
</th>
192187
</tr>
193188
}

web/pages/envelope_templ.go

+13-30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/pages/index.templ

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ templ indexView(m meta.Meta, props indexViewProps) {
8888
</tr>
8989
<tr>
9090
<th>Date</th>
91-
<td>{ build.Current.Date }</td>
91+
<td>@c.FormatDateString(m, build.Current.Date)</td>
9292
</tr>
9393
<tr>
9494
<th>Version</th>

web/pages/index_templ.go

+7-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)