feat: Legal checkboxes (#14)
commit28a23b5a57Author: Minecon724 <minecon724@noreply.git.m724.eu> Date: Sat Sep 13 11:57:09 2025 +0000 Add the form commit3fed792929Author: Minecon724 <minecon724@noreply.git.m724.eu> Date: Sat Sep 13 11:56:59 2025 +0000 Add the config option
This commit is contained in:
		
					parent
					
						
							
								f3ade85177
							
						
					
				
			
			
				commit
				
					
						3a97073f7b
					
				
			
		
					 9 changed files with 51 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -2459,6 +2459,10 @@ LEVEL = Info
 | 
			
		|||
;ENABLE_SITEMAP = true
 | 
			
		||||
;; Enable/Disable RSS/Atom feed
 | 
			
		||||
;ENABLE_FEED = true
 | 
			
		||||
;; Terms of Service URL. If set, users will have to agree to the ToS during registration.
 | 
			
		||||
;TERMS_OF_SERVICE = /terms
 | 
			
		||||
;; Privacy Policy URL. If set, users will have to agree to the Privacy Policy during registration.
 | 
			
		||||
;PRIVACY_POLICY = /privacy
 | 
			
		||||
 | 
			
		||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 | 
			
		||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,6 +11,8 @@ type OtherConfig struct {
 | 
			
		|||
	ShowFooterPoweredBy        bool
 | 
			
		||||
	EnableFeed                 bool
 | 
			
		||||
	EnableSitemap              bool
 | 
			
		||||
	TermsOfServiceUrl          string
 | 
			
		||||
	PrivacyPolicyUrl           string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var Other = OtherConfig{
 | 
			
		||||
| 
						 | 
				
			
			@ -19,6 +21,8 @@ var Other = OtherConfig{
 | 
			
		|||
	ShowFooterPoweredBy:        true,
 | 
			
		||||
	EnableSitemap:              true,
 | 
			
		||||
	EnableFeed:                 true,
 | 
			
		||||
	TermsOfServiceUrl:          "",
 | 
			
		||||
	PrivacyPolicyUrl:           "",
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func loadOtherFrom(rootCfg ConfigProvider) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -53,6 +53,8 @@ func CommonTemplateContextData() ContextData {
 | 
			
		|||
		"ShowMilestonesDashboardPage":   setting.Service.ShowMilestonesDashboardPage,
 | 
			
		||||
		"ShowFooterVersion":             setting.Other.ShowFooterVersion,
 | 
			
		||||
		"DisableDownloadSourceArchives": setting.Repository.DisableDownloadSourceArchives,
 | 
			
		||||
		"TermsOfServiceURL":             setting.Other.TermsOfServiceUrl,
 | 
			
		||||
		"PrivacyPolicyURL":              setting.Other.PrivacyPolicyUrl,
 | 
			
		||||
 | 
			
		||||
		"EnableSwagger":      setting.API.EnableSwagger,
 | 
			
		||||
		"EnableOpenIDSignIn": setting.Service.EnableOpenIDSignIn,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,6 +27,8 @@ licenses = Licenses
 | 
			
		|||
return_to_forgejo = Return to Forgejo
 | 
			
		||||
toggle_menu = Toggle menu
 | 
			
		||||
more_items = More items
 | 
			
		||||
terms_of_service = Terms of Service
 | 
			
		||||
privacy_policy = Privacy Policy
 | 
			
		||||
 | 
			
		||||
username = Username
 | 
			
		||||
email = Email address
 | 
			
		||||
| 
						 | 
				
			
			@ -37,6 +39,8 @@ captcha = CAPTCHA
 | 
			
		|||
twofa = Two-factor authentication
 | 
			
		||||
twofa_scratch = Two-factor scratch code
 | 
			
		||||
passcode = Passcode
 | 
			
		||||
consent.terms_of_service = I have read and agree to the <a href="%s">Terms of Service</a>
 | 
			
		||||
consent.privacy_policy = I have read and 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.
 | 
			
		||||
| 
						 | 
				
			
			@ -479,6 +483,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 = You must agree to the Terms of Service and Privacy Policy to register an account.
 | 
			
		||||
 | 
			
		||||
[mail]
 | 
			
		||||
view_it_on = View it on %s
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -448,6 +448,11 @@ func SignUpPost(ctx *context.Context) {
 | 
			
		|||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !form.ConsentTerms || !form.ConsentPrivacy {
 | 
			
		||||
		ctx.RenderWithErr(ctx.Tr("auth.must_consent"), tplSignUp, &form)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	context.VerifyCaptcha(ctx, tplSignUp, form)
 | 
			
		||||
	if ctx.Written() {
 | 
			
		||||
		return
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -92,10 +92,12 @@ func (f *InstallForm) Validate(req *http.Request, errs binding.Errors) binding.E
 | 
			
		|||
 | 
			
		||||
// RegisterForm form for registering
 | 
			
		||||
type RegisterForm struct {
 | 
			
		||||
	UserName string `binding:"Required;Username;MaxSize(40)"`
 | 
			
		||||
	Email    string `binding:"Required;MaxSize(254)"`
 | 
			
		||||
	Password string `binding:"MaxSize(255)"`
 | 
			
		||||
	Retype   string
 | 
			
		||||
	UserName       string `binding:"Required;Username;MaxSize(40)"`
 | 
			
		||||
	Email          string `binding:"Required;MaxSize(254)"`
 | 
			
		||||
	Password       string `binding:"MaxSize(255)"`
 | 
			
		||||
	Retype         string
 | 
			
		||||
	ConsentTerms   bool
 | 
			
		||||
	ConsentPrivacy bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Validate validates the fields
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,8 +25,9 @@
 | 
			
		|||
				{{end}}
 | 
			
		||||
			</div>
 | 
			
		||||
		</div>
 | 
			
		||||
		{{if .TermsOfServiceURL}}<a href="{{.TermsOfServiceURL}}">{{ctx.Locale.Tr "terms_of_service"}}</a>{{end}}
 | 
			
		||||
		{{if .PrivacyPolicyURL}}<a href="{{.PrivacyPolicyURL}}">{{ctx.Locale.Tr "privacy_policy"}}</a>{{end}}
 | 
			
		||||
		<a href="{{AssetUrlPrefix}}/licenses.txt">{{ctx.Locale.Tr "licenses"}}</a>
 | 
			
		||||
		{{if .EnableSwagger}}<a href="{{AppSubUrl}}/api/swagger">API</a>{{end}}
 | 
			
		||||
		{{template "custom/extra_links_footer" .}}
 | 
			
		||||
	</div>
 | 
			
		||||
</footer>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										21
									
								
								templates/user/auth/consent.tmpl
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								templates/user/auth/consent.tmpl
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,21 @@
 | 
			
		|||
{{ if (.TermsOfServiceURL) }}
 | 
			
		||||
  <div class="inline field required">
 | 
			
		||||
    <div class="ui checkbox">
 | 
			
		||||
      <input id="consent_terms" name="consent_terms" type="checkbox">
 | 
			
		||||
      <label for="consent_terms">{{ ctx.Locale.Tr "consent.terms_of_service" .TermsOfServiceURL }}</label>
 | 
			
		||||
    </div>
 | 
			
		||||
  </div>
 | 
			
		||||
{{ else }}
 | 
			
		||||
  <input id="consent_terms" name="consent_terms" type="checkbox" checked hidden>
 | 
			
		||||
{{ end }}
 | 
			
		||||
 | 
			
		||||
{{ if (.PrivacyPolicyURL) }}
 | 
			
		||||
  <div class="inline field required">
 | 
			
		||||
    <div class="ui checkbox">
 | 
			
		||||
      <input id="consent_privacy" name="consent_privacy" type="checkbox">
 | 
			
		||||
      <label for="consent_privacy">{{ ctx.Locale.Tr "consent.privacy_policy" .PrivacyPolicyURL }}</label>
 | 
			
		||||
    </div>
 | 
			
		||||
  </div>
 | 
			
		||||
{{ else }}
 | 
			
		||||
  <input id="consent_privacy" name="consent_privacy" type="checkbox" checked hidden>
 | 
			
		||||
{{ end }}
 | 
			
		||||
| 
						 | 
				
			
			@ -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}}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue