Files
gitocean/templates/moderation/new_abuse_report.tmpl
GustedandGusted a4642af51a feat: replace cross origin protection (#9830)
Replace the anti-CSRF token with a [cross origin protection by Go](https://go.dev/doc/go1.25#nethttppkgnethttp) that uses a stateless way of verifying if a request was cross origin or not. This allows is to remove al lot of code and replace it with a few lines of code and we no longer have to hand roll this protection. The new protection uses indicators by the browser itself that indicate if the request is cross-origin, thus we no longer have to take care of ensuring the generated CSRF token is passed back to the server any request by the the browser will have send this indicator.

Resolves forgejo/forgejo#3538

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9830
Reviewed-by: oliverpool <oliverpool@noreply.codeberg.org>
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>
2025-10-29 22:43:22 +01:00

45 lines
1.9 KiB
Go HTML Template

{{template "base/head" .}}
<div role="main" aria-label="{{.Title}}" class="page-content moderation new-report">
<div class="ui middle very relaxed page grid">
<div class="column">
<form class="ui form" action="{{.Link}}" method="post">
<h3 class="ui top attached header">
{{ctx.Locale.Tr "moderation.report_abuse_form.header"}}
</h3>
<div class="ui attached segment">
{{template "base/alert" .}}
<p class="ui center">{{ctx.Locale.Tr "moderation.report_abuse_form.details"}}</p>
<input type="hidden" name="content_id" value="{{.ContentID}}" />
<input type="hidden" name="content_type" value="{{.ContentType}}" />
<fieldset{{if not .ContentID}} disabled{{end}}>
<label{{if .Err_AbuseCategory}} class="field error"{{end}}>
{{ctx.Locale.Tr "moderation.abuse_category"}}
<select class="ui selection dropdown" id="abuse_category" name="abuse_category" required autofocus>
<option value="">{{ctx.Locale.Tr "moderation.abuse_category.placeholder"}}</option>
{{range $cat := .AbuseCategories}}
<option value="{{$cat.Value}}"{{if eq $.abuse_category $cat.Value}} selected{{end}}>{{ctx.Locale.Tr $cat.TranslationKey}}</option>
{{end}}
</select>
</label>
<label{{if .Err_Remarks}} class="field error"{{end}}>
{{ctx.Locale.Tr "moderation.report_remarks"}}
<textarea id="remarks" name="remarks" required minlength="20" maxlength="500" placeholder="{{ctx.Locale.Tr "moderation.report_remarks.placeholder"}}">{{.remarks}}</textarea>
</label>
</fieldset>
<div class="divider"></div>
<div class="text right actions">
<a class="ui cancel button" href="{{$.CancelLink}}">{{ctx.Locale.Tr "cancel"}}</a>
{{if .ContentID}}
<button class="ui primary button">{{ctx.Locale.Tr "moderation.submit_report"}}</button>
{{end}}
</div>
</div>
</form>
</div>
</div>
</div>
{{template "base/footer" .}}