Commit 65158fd2 authored by Alain Takoudjou's avatar Alain Takoudjou

Save username to cookie, autostart video on loggin

parent 9dd6abae
...@@ -117,11 +117,11 @@ ...@@ -117,11 +117,11 @@
<label for="username">Username</label> <label for="username">Username</label>
<input id="username" type="text" name="username" <input id="username" type="text" name="username"
autocomplete="username" class="form-control"/> autocomplete="username" class="form-control"/>
<label for="password">Password</label> <label for="password" class="invisible">Password</label>
<input id="password" type="password" name="password" <input id="password" type="password" name="password" readonly
autocomplete="current-password" class="form-control"/> autocomplete="current-password" class="form-control invisible"/>
<label>Enable at start:</label> <label class="invisible">Enable at start:</label>
<div class="present-switch"> <div class="present-switch invisible">
<!--<p class="switch-radio"> <!--<p class="switch-radio">
<input id="presentoff" type="radio" name="presentradio" value=""/> <input id="presentoff" type="radio" name="presentradio" value=""/>
<label for="presentoff">Nothing</label> <label for="presentoff">Nothing</label>
......
...@@ -314,6 +314,7 @@ async function gotConnected(username) { ...@@ -314,6 +314,7 @@ async function gotConnected(username) {
username = getInputElement('username').value.trim(); username = getInputElement('username').value.trim();
let pw = getInputElement('password').value; let pw = getInputElement('password').value;
getInputElement('password').value = ''; getInputElement('password').value = '';
if(!groupStatus.authServer) if(!groupStatus.authServer)
credentials = pw; credentials = pw;
else else
...@@ -2404,6 +2405,7 @@ async function gotJoined(kind, group, perms, status, data, message) { ...@@ -2404,6 +2405,7 @@ async function gotJoined(kind, group, perms, status, data, message) {
setTitle((status && status.displayName) || capitalise(group)); setTitle((status && status.displayName) || capitalise(group));
displayUsername(); displayUsername();
setButtonsVisibility(); setButtonsVisibility();
setUsernameCookie(serverConnection.username);
if(kind === 'change') if(kind === 'change')
return; return;
break; break;
...@@ -4002,6 +4004,27 @@ async function serverConnect() { ...@@ -4002,6 +4004,27 @@ async function serverConnect() {
} }
} }
function getUsernameCookie() {
let user = document.cookie.split("; ")
.find((row) => row.startsWith("u="));
if(user) {
return user.split('=')[1];
}
return "";
}
/**
* @param {string} username
*/
function setUsernameCookie(username) {
deleteUsernameCookie();
document.cookie = 'u=' + username + '; path=/';
}
function deleteUsernameCookie() {
document.cookie = 'u=; Max-Age=0; path=/';
}
async function start() { async function start() {
group = decodeURIComponent( group = decodeURIComponent(
location.pathname.replace(/^\/[a-z]*\//, '').replace(/\/$/, '') location.pathname.replace(/^\/[a-z]*\//, '').replace(/\/$/, '')
...@@ -4019,6 +4042,7 @@ async function start() { ...@@ -4019,6 +4042,7 @@ async function start() {
} }
let parms = new URLSearchParams(window.location.search); let parms = new URLSearchParams(window.location.search);
let username = getUsernameCookie();
if(window.location.search) if(window.location.search)
window.history.replaceState(null, '', window.location.pathname); window.history.replaceState(null, '', window.location.pathname);
setTitle(groupStatus.displayName || capitalise(group)); setTitle(groupStatus.displayName || capitalise(group));
...@@ -4031,9 +4055,9 @@ async function start() { ...@@ -4031,9 +4055,9 @@ async function start() {
await serverConnect(); await serverConnect();
} else if(groupStatus.authPortal) { } else if(groupStatus.authPortal) {
window.location.href = groupStatus.authPortal; window.location.href = groupStatus.authPortal;
} else if(window.location.hash) { } else if(username) {
let connect = document.getElementById('connectbutton'); let connect = document.getElementById('connectbutton');
getInputElement('username').value = window.location.hash.slice(1); getInputElement('username').value = username;
getInputElement('password').value = ""; getInputElement('password').value = "";
connect.click(); connect.click();
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment