diff --git a/.env.template b/.env.template index 484bc21..3dcafdf 100644 --- a/.env.template +++ b/.env.template @@ -4,6 +4,11 @@ SSL=false # true or false DOMAIN=localhost PORT=8000 +# Host + +HOST_PASSWORD_ENABLED=false # true or false +HOST_PASSWORD='123456789' + # Stun STUN_SERVER_ENABLED=true # true or false @@ -17,11 +22,6 @@ TURN_SERVER_URL=turn:a.relay.metered.ca:443 TURN_SERVER_USERNAME=e8dd65b92c62d3e36cafb807 TURN_SERVER_CREDENTIAL=uWdWNmkhvyqTEswO -# Room - -ROOM_PASSWORD_ENABLED=false # true or false -ROOM_PASSWORD='123456789' - # API API_KEY_SECRET=call_me_api_key_secret # change me diff --git a/app/server.js b/app/server.js index b6eb227..e291263 100755 --- a/app/server.js +++ b/app/server.js @@ -31,8 +31,8 @@ const config = { turnServerUrl: process.env.TURN_SERVER_URL, turnServerUsername: process.env.TURN_SERVER_USERNAME, turnServerCredential: process.env.TURN_SERVER_CREDENTIAL, - roomPasswordEnabled: process.env.ROOM_PASSWORD_ENABLED === 'true', - roomPassword: process.env.ROOM_PASSWORD || '', + hostPasswordEnabled: process.env.HOST_PASSWORD_ENABLED === 'true', + hostPassword: process.env.HOST_PASSWORD || '', apiKeySecret: process.env.API_KEY_SECRET, randomImageUrl: process.env.RANDOM_IMAGE_URL || '', apiBasePath: '/api/v1', @@ -40,7 +40,7 @@ const config = { }; // If no room password is specified, a random one is generated (if room password is enabled) -config.roomPassword = process.env.ROOM_PASSWORD || (config.roomPasswordEnabled ? generatePassword() : ''); +config.hostPassword = process.env.HOST_PASSWORD || (config.hostPasswordEnabled ? generatePassword() : ''); // Add STUN server if enabled and URL is provided if (config.stunServerEnabled && config.stunServerUrl) { @@ -95,9 +95,9 @@ server.listen(port, () => { console.log('Server', { running_at: host, ice: config.iceServers, - room: { - password_enabled: config.roomPasswordEnabled, - password: config.roomPassword, + host: { + password_enabled: config.hostPasswordEnabled, + password: config.hostPassword, }, api_key_secret: config.apiKeySecret, api_docs: apiDocs, @@ -152,7 +152,7 @@ app.get('/join/', (req, res) => { // http://localhost:8000/join?user=user1&password=123456789 // http://localhost:8000/join?user=user2&call=user1&password=123456789 - if (config.roomPasswordEnabled && password !== config.roomPassword) { + if (config.hostPasswordEnabled && password !== config.hostPassword) { return unauthorized(res); } @@ -217,15 +217,15 @@ app.get(`${config.apiBasePath}/users`, (req, res) => { }); // Check if Room password required -app.get('/api/roomPassword', (req, res) => { - const isPasswordRequired = config.roomPasswordEnabled; +app.get('/api/hostPassword', (req, res) => { + const isPasswordRequired = config.hostPasswordEnabled; res.json({ isPasswordRequired }); }); // Check if Room password valid -app.post('/api/roomPasswordValidate', (req, res) => { +app.post('/api/hostPasswordValidate', (req, res) => { const { password } = req.body; - const success = password === config.roomPassword; + const success = password === config.hostPassword; res.json({ success: success }); }); diff --git a/package.json b/package.json index 8785cea..8109bf9 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "call-me", - "version": "1.0.36", + "version": "1.0.37", "description": "Your Go-To for Instant Video Calls", "author": "Miroslav Pejic - miroslav.pejic.85@gmail.com", "license": "AGPLv3", diff --git a/public/assets/locked.png b/public/assets/locked.png new file mode 100644 index 0000000..4252444 Binary files /dev/null and b/public/assets/locked.png differ diff --git a/public/client.js b/public/client.js index 598b6d5..e629098 100755 --- a/public/client.js +++ b/public/client.js @@ -44,22 +44,25 @@ document.addEventListener('DOMContentLoaded', function () { // githubDiv.style.display = 'none'; -async function checkRoomPassword(maxRetries = 3, attempts = 0) { +async function checkHostPassword(maxRetries = 3, attempts = 0) { try { - // Fetch room configuration - const { data: config } = await axios.get('/api/roomPassword'); + // Fetch host configuration + const { data: config } = await axios.get('/api/hostPassword'); if (config.isPasswordRequired) { // Show prompt for the password const { value: password } = await Swal.fire({ - title: 'Room Protected', - text: 'Please enter the room password:', + title: 'Host Protected', + text: 'Please enter the host password:', input: 'password', inputPlaceholder: 'Enter your password', inputAttributes: { autocapitalize: 'off', autocorrect: 'off', }, + imageUrl: 'assets/locked.png', + imageWidth: 150, + imageHeight: 150, allowOutsideClick: false, allowEscapeKey: false, showDenyButton: true, @@ -79,7 +82,7 @@ async function checkRoomPassword(maxRetries = 3, attempts = 0) { } // Validate the password - const { data: validationResult } = await axios.post('/api/roomPasswordValidate', { password }); + const { data: validationResult } = await axios.post('/api/hostPasswordValidate', { password }); if (validationResult.success) { await Swal.fire({ @@ -99,7 +102,7 @@ async function checkRoomPassword(maxRetries = 3, attempts = 0) { text: `Please try again. (${attempts}/${maxRetries} attempts)`, }); // Retry the process - checkRoomPassword(maxRetries, attempts); + checkHostPassword(maxRetries, attempts); } else { await Swal.fire({ icon: 'warning', @@ -117,7 +120,7 @@ async function checkRoomPassword(maxRetries = 3, attempts = 0) { Swal.fire({ icon: 'error', title: 'Error', - text: 'An error occurred while joining the room.', + text: 'An error occurred while joining the host.', }); } } @@ -187,7 +190,7 @@ function handleDirectJoin() { } } - if (!password) checkRoomPassword(); + if (!password) checkHostPassword(); } // Session Time