refactor: migrate from bcrypt.js to Nginx basic authentication

This commit is contained in:
Greg 2025-05-27 00:51:03 +02:00
parent 4dd08654c8
commit bdbe781bef
2 changed files with 9 additions and 21 deletions

View File

@ -6,10 +6,7 @@
<title>Keep My Weight - Personal Weight & Meal Tracker</title> <title>Keep My Weight - Personal Weight & Meal Tracker</title>
<link rel="stylesheet" href="css/styles.css"> <link rel="stylesheet" href="css/styles.css">
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>⚖️</text></svg>"> <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>⚖️</text></svg>">
<!-- Password hash for authentication (will be replaced by server) --> <!-- Authentication is now handled by Nginx -->
<meta name="password-hash" content="$PASSWORD_HASH$">
<!-- bcrypt.js for password verification -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/bcryptjs/2.4.3/bcrypt.min.js"></script>
</head> </head>
<body> <body>
<div class="app-container"> <div class="app-container">
@ -207,7 +204,6 @@
<script src="js/dataManager.js"></script> <script src="js/dataManager.js"></script>
<script src="js/ui.js"></script> <script src="js/ui.js"></script>
<script src="js/charts.js"></script> <script src="js/charts.js"></script>
<script src="js/auth.js"></script>
<script src="js/app.js"></script> <script src="js/app.js"></script>
</body> </body>
</html> </html>

View File

@ -3,10 +3,7 @@
* Entry point for the application, initializes all components * Entry point for the application, initializes all components
*/ */
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
// Initialize authentication first // Initialize all modules
Auth.init();
// Initialize all other modules
DataManager.init(); DataManager.init();
UI.init(); UI.init();
Charts.init(); Charts.init();
@ -15,22 +12,17 @@ document.addEventListener('DOMContentLoaded', () => {
UI.renderWeightTable(); UI.renderWeightTable();
UI.renderMealTable(); UI.renderMealTable();
// Add logout button to settings tab // Add security information to settings tab
const settingsCard = document.querySelector('#settings-content .card:last-child'); const settingsCard = document.querySelector('#settings-content .card:last-child');
if (settingsCard) { if (settingsCard) {
const logoutSection = document.createElement('div'); const securitySection = document.createElement('div');
logoutSection.className = 'form-group'; securitySection.className = 'form-group';
logoutSection.innerHTML = ` securitySection.innerHTML = `
<h3>Security</h3> <h3>Security</h3>
<p>Log out of your weight tracker application</p> <p>Your data is protected by Nginx basic authentication.</p>
<button id="logout-button" class="btn secondary-btn">Logout</button> <p>To log out, close your browser or clear your browser's authentication cache.</p>
`; `;
settingsCard.appendChild(logoutSection); settingsCard.appendChild(securitySection);
// Add logout functionality
document.getElementById('logout-button').addEventListener('click', () => {
Auth.logout();
});
} }
console.log('Weight Tracker app initialized successfully'); console.log('Weight Tracker app initialized successfully');