Add global registration disable feature

Implement configurable registration control to allow administrators to disable new user signups.

Backend changes:
- Add fitpub.registration.enabled configuration property (defaults to true)
- Update AuthController to check registration status and return 403 Forbidden when disabled
- Create GET /api/auth/registration-status endpoint to expose registration status to frontend
- Add RegistrationStatusResponse DTO

Configuration changes:
- Add REGISTRATION_ENABLED environment variable to application.yml
- Add REGISTRATION_ENABLED to Dockerfile with default value of true
- Update .env.example with REGISTRATION_ENABLED documentation

Frontend changes:
- Update registration page to check status and hide form when disabled
- Add checkRegistrationStatus() to auth.js to dynamically hide registration links
- Display user-friendly message when registration is disabled

To disable registration, set environment variable: REGISTRATION_ENABLED=false

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Tim Zöller 2025-12-03 11:27:19 +01:00
parent 0732774986
commit bc6741a749
6 changed files with 82 additions and 1 deletions

View file

@ -173,6 +173,9 @@ const FitPubAuth = {
// Update navigation UI based on auth status
this.updateNavigationUI();
// Check registration status and update UI
this.checkRegistrationStatus();
// Check authentication status on page load
this.checkAuthStatus();
@ -180,6 +183,30 @@ const FitPubAuth = {
this.setupExpirationWarning();
},
/**
* Check if registration is enabled and update navigation UI
*/
checkRegistrationStatus: async function() {
try {
const response = await fetch('/api/auth/registration-status');
const data = await response.json();
if (!data.enabled) {
// Hide registration link in navigation
const registerLinks = document.querySelectorAll('a[href="/register"]');
registerLinks.forEach(link => {
const parent = link.parentElement;
if (parent && parent.tagName === 'LI') {
parent.style.display = 'none';
}
});
}
} catch (error) {
console.error('Error checking registration status:', error);
// Continue without hiding registration link if check fails
}
},
/**
* Update navigation UI based on authentication status
*/