From 89b8b8149378a1a73a258efaa6d3c58a30dc79a9 Mon Sep 17 00:00:00 2001 From: Miroslav Pejic Date: Sat, 28 Dec 2024 20:45:40 +0100 Subject: [PATCH] [call-me] - #3 change room with host... --- .env.template | 10 +++++----- app/server.js | 22 +++++++++++----------- package.json | 2 +- public/assets/locked.png | Bin 0 -> 3290 bytes public/client.js | 21 ++++++++++++--------- 5 files changed, 29 insertions(+), 26 deletions(-) create mode 100644 public/assets/locked.png 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 0000000000000000000000000000000000000000..42524443c87c0ca30632cc536c97f05082a4b913 GIT binary patch literal 3290 zcmV<03?=i4P)Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91fS>~a1ONa40RR91fB*mh07#AmcK`qkL`g(JRCodHU2BXSM-i^-+1&&C ze7?K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#oouB0JLT6@M5Q{_&-!d+DImiJpnjpe{>od20Zqkv&EhOvU`^ZU^yUxMc+F<=|C@1 zDzPVk?AvF6hpUc?U{9p8oo`jG7cqs{6F|m8_U+TppDK=xz*o}Qiw{f&g-0 zCp|X3jRE_SZL9=)ES=*T@!%5_?%MtBG-A&x~>6C;4i7lliQxioiFmEXLsiF zr<+u1wG2RFG(I}`IWx)s$+_65!h{P{Vz1Jjm${y_kw1T?U9jXi%Fvk4RR7ij0W{H? z>2|wmllgt}>lz&63BJ|q;7f}%< YFB-{kKFB4>c>n+a07*qoM6N<$f&fV%(*OVf literal 0 HcmV?d00001 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