-
Notifications
You must be signed in to change notification settings - Fork 0
/
change_creds.js
50 lines (40 loc) · 1.35 KB
/
change_creds.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const keytar = require('keytar');
const _pass = document.getElementById('_pass');
const _user = document.getElementById('_user');
const _form = document.getElementById('_form');
const loading = document.getElementById("lds-container")
const LoadingStart = ()=>{
loading.innerHTML = `<div class="lds-spinner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>`;
}
const LoadingEnd = ()=>{
loading.innerHTML = "";
}
let user = "";
let pass = "";
const setKeyAndPass = async ()=>{
const ked = await keytar.findCredentials('iitg_autologin_app').then(res=>res);
console.log(ked)
ked.forEach(k=>{
keytar.deletePassword('iitg_autologin_app', k.account)
})
const res = await keytar.setPassword('iitg_autologin_app', user, pass);
const ke = await keytar.findCredentials('iitg_autologin_app').then(res=>res);
console.log(ke)
LoadingEnd();
}
const formSubmitHandler = async (e)=>{
e.preventDefault();
LoadingStart();
await setKeyAndPass();
}
const userInputHandler = (e)=>{
user = e.target.value;
// console.log(user)
}
const passInputHandler = (e)=>{
pass = e.target.value;
// console.log(pass)
}
_user.addEventListener('input', userInputHandler);
_pass.addEventListener('input', passInputHandler);
_form.addEventListener('submit', formSubmitHandler);