Skip to content

Commit

Permalink
Fix password is always saved issue #130
Browse files Browse the repository at this point in the history
  • Loading branch information
ClassicOldSong committed Dec 3, 2024
1 parent 9ac9c18 commit 7d3b695
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src_assets/common/assets/web/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h1 class="mb-0">
{{ $t('welcome.greeting') }}
</h1>
</header>
<form @submit.prevent="save" class="mt-4">
<form @submit.prevent="login" class="mt-4">
<div class="mb-2">
<label for="usernameInput" class="form-label">{{ $t('_common.username') }}</label>
<input type="text" class="form-control" id="usernameInput" autocomplete="username"
Expand Down Expand Up @@ -82,17 +82,22 @@ <h1 class="mb-0">
return data
},
methods: {
save() {
login() {
this.error = null;
this.loading = true;
if (!this.savePassword) {
localStorage.removeItem('login')
}
fetch("./api/login", {
method: "POST",
body: JSON.stringify(this.passwordData),
}).then((res) => {
this.loading = false;
if (res.status === 200) {
this.success = true;
localStorage.setItem('login', JSON.stringify(this.passwordData));
if (this.savePassword) {
localStorage.setItem('login', JSON.stringify(this.passwordData));
}
const url = new URL(window.location);
const redirectUrl = url.searchParams.get('redir');
const hash = url.hash;
Expand Down

0 comments on commit 7d3b695

Please sign in to comment.