Remove white spaces from secrets

Fix #1
This commit is contained in:
Corentin 2023-03-20 06:26:20 +09:00
commit d2baffb5d4
2 changed files with 7 additions and 5 deletions

View file

@ -14,7 +14,7 @@
<form id="password-form"> <form id="password-form">
<label for="master-password">Password</label> <label for="master-password">Password</label>
<div class="password-container"> <div class="password-container">
<input type="password" id="master-password" autofocus /> <input type="password" id="master-password" autofocus autocomplete="off" />
<img id="master-visibility" class="icon visibility" src="/icons/visibility.svg" /> <img id="master-visibility" class="icon visibility" src="/icons/visibility.svg" />
</div> </div>
<button>Open</button> <button>Open</button>
@ -25,12 +25,12 @@
<form id="entry-form"> <form id="entry-form">
<div> <div>
<label for="entry-name">Name</label> <label for="entry-name">Name</label>
<input type="text" id="entry-name" required /> <input type="text" id="entry-name" autocomplete="off" required />
</div> </div>
<div> <div>
<label for="entry-secret">Secret</label> <label for="entry-secret">Secret</label>
<div class="password-container"> <div class="password-container">
<input type="password" id="entry-secret" required /> <input type="password" id="entry-secret" autocomplete="off" required />
<img id="entry-visibility" class="icon visibility" src="/icons/visibility.svg" /> <img id="entry-visibility" class="icon visibility" src="/icons/visibility.svg" />
</div> </div>
<button><img class="icon" src="/icons/add.svg" title="Add"></button> <button><img class="icon" src="/icons/add.svg" title="Add"></button>

View file

@ -424,7 +424,8 @@ class Entry
done_elt.addEventListener('click', () => { done_elt.addEventListener('click', () => {
this.name = name_input_elt.value this.name = name_input_elt.value
this.elements.title.textContent = this.name this.elements.title.textContent = this.name
this.secret = secret_input_elt.value // Remove any white spaces (can happen for readability)
this.secret = secret_input_elt.value.replace(/\s/g, '')
this.regenerateKey().then(() => { this.regenerateKey().then(() => {
const count_time = Date.now() / 30000 const count_time = Date.now() / 30000
const counter = Math.floor(count_time) const counter = Math.floor(count_time)
@ -460,7 +461,8 @@ class Entry
async function addEntry(event) async function addEntry(event)
{ {
event.preventDefault() event.preventDefault()
await store.addEntry(entry_name_elt.value, entry_secret_elt.value) // Remove any white spaces (can happen for readability)
await store.addEntry(entry_name_elt.value, entry_secret_elt.value.replace(/\s/g, ''))
} }
function start() function start()