Privacy policy support
Some checks are pending
/ release (push) Waiting to run
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-e2e (push) Blocked by required conditions
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions

Signed-off-by: Minecon724 <minecon724@noreply.git.m724.eu>
This commit is contained in:
Minecon724 2025-03-21 07:53:55 +01:00
parent bbd750897e
commit 7f6b6fc461
Signed by: Minecon724
GPG key ID: A02E6E67AB961189
8 changed files with 27 additions and 1 deletions

View file

@ -85,6 +85,7 @@ var Service = struct {
DefaultOrgMemberVisible bool
UserDeleteWithCommentsMaxTime time.Duration
ValidSiteURLSchemes []string
PrivacyPolicyURL string
// OpenID settings
EnableOpenIDSignIn bool
@ -263,6 +264,8 @@ func loadServiceFrom(rootCfg ConfigProvider) {
}
Service.ValidSiteURLSchemes = schemes
Service.PrivacyPolicyURL = sec.Key("PRIVACY_POLICY_URL").MustString("")
mustMapSetting(rootCfg, "service.explore", &Service.Explore)
loadOpenIDSetting(rootCfg)

View file

@ -59,5 +59,6 @@ func CommonTemplateContextData() ContextData {
"PageStartTime": time.Now(),
"RunModeIsProd": setting.IsProd,
"PrivacyPolicyURL": setting.Service.PrivacyPolicyURL,
}
}

View file

@ -28,6 +28,7 @@ licenses = Licenses
return_to_forgejo = Return to Forgejo
toggle_menu = Toggle menu
more_items = More items
privacy_policy = Privacy Policy
username = Username
email = Email address
@ -38,6 +39,7 @@ captcha = CAPTCHA
twofa = Two-factor authentication
twofa_scratch = Two-factor scratch code
passcode = Passcode
consent_agree = I agree to the <a href="%s">Privacy Policy</a>
webauthn_insert_key = Insert your security key
webauthn_sign_in = Press the button on your security key. If your security key has no button, re-insert it.
@ -486,6 +488,7 @@ password_pwned_err = Could not complete request to HaveIBeenPwned
last_admin = You cannot remove the last admin. There must be at least one admin.
back_to_sign_in = Back to Sign in
sign_in_openid = Proceed with OpenID
must_consent = Agreement to our Privacy Policy is required to register.
[mail]
view_it_on = View it on %s

View file

@ -457,6 +457,11 @@ func SignUpPost(ctx *context.Context) {
return
}
if !form.Consent {
ctx.RenderWithErr(ctx.Tr("auth.must_consent"), tplSignUp, &form)
return
}
context.VerifyCaptcha(ctx, tplSignUp, form)
if ctx.Written() {
return

View file

@ -96,6 +96,7 @@ type RegisterForm struct {
Email string `binding:"Required;MaxSize(254)"`
Password string `binding:"MaxSize(255)"`
Retype string
Consent bool // privacy policy consent
}
// Validate validates the fields

View file

@ -27,6 +27,7 @@
</div>
<a href="{{AssetUrlPrefix}}/licenses.txt">{{ctx.Locale.Tr "licenses"}}</a>
{{if .EnableSwagger}}<a href="{{AppSubUrl}}/api/swagger">API</a>{{end}}
{{if .PrivacyPolicyURL}}<a href="{{.PrivacyPolicyURL}}">{{ctx.Locale.Tr "privacy_policy"}}</a>{{end}}
{{template "custom/extra_links_footer" .}}
</div>
</footer>

View file

@ -0,0 +1,10 @@
{{ if (.PrivacyPolicyURL) }}
<div class="inline field required">
<div class="ui checkbox">
<input id="consent" name="consent" type="checkbox">
<label for="consent">{{ ctx.Locale.Tr "consent_agree" .PrivacyPolicyURL }}</label>
</div>
</div>
{{ else }}
<input id="consent" name="consent" type="checkbox" checked hidden>
{{ end }}

View file

@ -37,6 +37,8 @@
{{template "user/auth/captcha" .}}
{{template "user/auth/consent" .}}
<div class="inline field">
<button class="ui primary button tw-w-full">
{{if .LinkAccountMode}}