[mirotalk] - improvements

This commit is contained in:
Miroslav Pejic
2023-09-06 16:34:38 +02:00
parent adc2bb3e00
commit eba9c452f5
3 changed files with 28 additions and 11 deletions
+3 -6
View File
@@ -102,15 +102,12 @@
> **Note**
>
> When [host protection is enabled](https://github.com/miroslavpejic85/mirotalk/commit/285c92605585bf204996dc0bade9b3e7c62d75df#commitcomment-103108955), the URL format for direct room access after authentication should be as follows:
>
> - https://p2p.mirotalk.com/?room=test
> When [host protection is enabled](https://github.com/miroslavpejic85/mirotalk/commit/285c92605585bf204996dc0bade9b3e7c62d75df#commitcomment-103108955) the host needs to provide a valid username and password as specified in the `.env`.
>
> After host authentication, participants can join the room using any of the following URL formats:
>
> - https://p2p.mirotalk.com/join/test
> - https://p2p.mirotalk.com/join/?room=test
> - https://p2p.mirotalk.com/join/?room=test&name=mirotalk&audio=0&video=0&screen=0&notify=0
> - https://p2p.mirotalk.com/join/test (URL path)
> - https://p2p.mirotalk.com/join/?room=test&name=mirotalk&audio=0&video=0&screen=0&notify=0 (URL with query parameters for direct join)
</details>
+6
View File
@@ -328,6 +328,9 @@ app.get('/join/', (req, res) => {
return res.sendFile(views.client);
}
}
if (hostCfg.protected) {
return res.sendFile(views.login);
}
res.redirect('/');
});
@@ -337,6 +340,9 @@ app.get('/join/:roomId', function (req, res) {
if (hostCfg.authenticated) {
res.sendFile(views.client);
} else {
if (hostCfg.protected) {
return res.sendFile(views.login);
}
res.redirect('/');
}
});
+19 -5
View File
@@ -108,13 +108,12 @@
</div>
</div>
<script>
console.log(window.location);
const usernameInput = document.getElementById('username');
const passwordInput = document.getElementById('password');
const loginBtn = document.getElementById('loginButton');
const qs = new URLSearchParams(window.location.search);
const room = filterXSS(qs.get('room'));
usernameInput.onkeyup = (e) => {
if (e.keyCode === 13) {
e.preventDefault();
@@ -136,6 +135,15 @@
let username = filterXSS(document.getElementById('username').value);
let password = filterXSS(document.getElementById('password').value);
// http://localhost:3000/join/?room=test
// http://localhost:3000/join/?room=test&name=mirotalk&audio=0&video=0&screen=0&notify=0
const qs = new URLSearchParams(window.location.search);
const room = filterXSS(qs.get('room'));
// http://localhost:3000/join/test
const pathParts = window.location.pathname.split('/');
const roomPath = pathParts[pathParts.length - 1];
if (username && password) {
axios
.post('/login', {
@@ -144,10 +152,16 @@
})
.then(function (response) {
console.log(response);
// http://localhost:3010/?room=test
if (room) {
return (window.location.href = '/join/' + room);
return (window.location.href =
'/join/' + window.location.search);
}
if (roomPath) {
return (window.location.href = '/join/' + roomPath);
}
return (window.location.href = '/logged');
})
.catch(function (error) {