Merge pull request '#6656 addUserSignIn' (#18) from 6656-addUserSingIn into test
gitea/worker-time-control/pipeline/head This commit looks good Details

Reviewed-on: #18
This commit is contained in:
Jorge Penadés 2024-01-10 13:42:56 +00:00
commit 21720b7b27
2 changed files with 5 additions and 5 deletions

View File

@ -1,9 +1,7 @@
let pin = ""; let pin = "";
let pass = "";
$(document).ready(function () { $(document).ready(function () {
FastClick.attach(document.body); FastClick.attach(document.body);
if(!localStorage.getItem('user')) localStorage.setItem('user', user);
setEvents(); setEvents();
}); });
@ -14,13 +12,15 @@ function setEvents() {
Swal.fire({ Swal.fire({
title: 'Iniciar sesión', title: 'Iniciar sesión',
html: html:
'<input id="pass" class="swal2-input" type="password" placeholder="Contraseña">', `<input id="user" class="swal2-input" type="text" placeholder="Usuario" value="${localStorage.getItem('user') ?? ''}">
<input id="pass" class="swal2-input" type="password" placeholder="Contraseña">`,
confirmButtonText: 'Login', confirmButtonText: 'Login',
showCloseButton: true, showCloseButton: true,
showCancelButton: false, showCancelButton: false,
}).then(async (result) => { }).then(async (result) => {
if(result.isConfirmed) { if(result.isConfirmed) {
pass = $('#pass').val(); const user = $('#user').val();
const pass = $('#pass').val();
signIn(user,pass); signIn(user,pass);
} }
}); });
@ -64,6 +64,7 @@ function signIn(user, password) {
success: function (data) { success: function (data) {
localStorage.setItem("token", data.token); localStorage.setItem("token", data.token);
localStorage.setItem("ttl", data.ttl); localStorage.setItem("ttl", data.ttl);
localStorage.setItem("user", user);
localStorage.setItem("password", password); localStorage.setItem("password", password);
localStorage.setItem("created", Date.now()); localStorage.setItem("created", Date.now());
getTokenConfig(); getTokenConfig();

View File

@ -1,4 +1,3 @@
const user = "timeControl";
const renewPeriod = localStorage.getItem('renewPeriod'); const renewPeriod = localStorage.getItem('renewPeriod');
let intervalId, isCheckingToken; let intervalId, isCheckingToken;