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:
parent
0732774986
commit
bc6741a749
6 changed files with 82 additions and 1 deletions
|
|
@ -174,7 +174,7 @@
|
|||
<!-- Custom Scripts -->
|
||||
<th:block layout:fragment="scripts">
|
||||
<script th:inline="javascript">
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.addEventListener('DOMContentLoaded', async function() {
|
||||
const form = document.getElementById('registerForm');
|
||||
const registerBtn = document.getElementById('registerBtn');
|
||||
const registerBtnText = document.getElementById('registerBtnText');
|
||||
|
|
@ -183,6 +183,23 @@
|
|||
const successAlert = document.getElementById('successAlert');
|
||||
const errorMessage = document.getElementById('errorMessage');
|
||||
|
||||
// Check if registration is enabled
|
||||
try {
|
||||
const response = await fetch('/api/auth/registration-status');
|
||||
const data = await response.json();
|
||||
|
||||
if (!data.enabled) {
|
||||
// Registration is disabled - show message and hide form
|
||||
errorMessage.textContent = 'Registration is currently disabled on this instance. Please contact the administrator if you need an account.';
|
||||
errorAlert.classList.remove('d-none');
|
||||
form.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error checking registration status:', error);
|
||||
// Continue to show form if check fails
|
||||
}
|
||||
|
||||
// Password confirmation validation
|
||||
const password = document.getElementById('password');
|
||||
const confirmPassword = document.getElementById('confirmPassword');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue