refactor: refs #6656 addUserSignIn
gitea/worker-time-control/pipeline/head This commit looks good Details

This commit is contained in:
jorgep 2024-01-10 10:31:47 +01:00
parent 81d578fbd6
commit 8d122e44bf
2 changed files with 5 additions and 5 deletions

View File

@ -1,9 +1,7 @@
let pin = "";
let pass = "";
$(document).ready(function () {
FastClick.attach(document.body);
if(!localStorage.getItem('user')) localStorage.setItem('user', user);
setEvents();
});
@ -14,13 +12,15 @@ function setEvents() {
Swal.fire({
title: 'Iniciar sesión',
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',
showCloseButton: true,
showCancelButton: false,
}).then(async (result) => {
if(result.isConfirmed) {
pass = $('#pass').val();
const user = $('#user').val();
const pass = $('#pass').val();
signIn(user,pass);
}
});
@ -64,6 +64,7 @@ function signIn(user, password) {
success: function (data) {
localStorage.setItem("token", data.token);
localStorage.setItem("ttl", data.ttl);
localStorage.setItem("user", user);
localStorage.setItem("password", password);
localStorage.setItem("created", Date.now());
getTokenConfig();

View File

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