hotfix: fixes session duration from #346

This commit is contained in:
Felipe M 2022-02-11 16:00:38 +01:00
parent 2dc462b010
commit 2ca628b7fe
No known key found for this signature in database
GPG key ID: 716BC147715E716F
3 changed files with 106 additions and 104 deletions

View file

@ -37,8 +37,10 @@
<label for="username">Username: </label>
<input id="username" type="text" name="username" placeholder="Username" tabindex="1">
<label for="password">Password: </label>
<input id="password" type="password" name="password" placeholder="Password" tabindex="2" @keyup.enter="login">
<label class="checkbox-field"><input type="checkbox" name="remember" v-model="remember" tabindex="3">Remember me</label>
<input id="password" type="password" name="password" placeholder="Password" tabindex="2"
@keyup.enter="login">
<label class="checkbox-field"><input type="checkbox" name="remember" v-model="remember"
tabindex="3">Remember me</label>
</div>
<div id="button-area">
<a v-if="loading">
@ -74,10 +76,10 @@
}
},
login() {
// needed to work around autofill issue
// https://github.com/facebook/react/issues/1159#issuecomment-506584346
this.username = document.querySelector('#username').value;
this.password = document.querySelector('#password').value;
// needed to work around autofill issue
// https://github.com/facebook/react/issues/1159#issuecomment-506584346
this.username = document.querySelector('#username').value;
this.password = document.querySelector('#password').value;
// Validate input
if (this.username === "") {
this.error = "Username must not empty";
@ -103,7 +105,7 @@
return response.json();
}).then(json => {
// Save session id
var sessionAge = this.remember == 1 ? 60 * 60 * 24 * 30 : 10
var sessionAge = this.remember == 1 ? 60 * 60 * 24 * 30 : 60 * 60
var expTime = new Date(Date.now() + sessionAge * 1000).toUTCString();
document.cookie = `session-id=${json.session}; Path=${new URL(document.baseURI).pathname}; Expires=${expTime}`;

File diff suppressed because one or more lines are too long

View file

@ -104,7 +104,7 @@ func (h *handler) apiLogin(w http.ResponseWriter, r *http.Request, ps httprouter
if request.Remember {
expTime = time.Hour * 24 * 30
} else {
expTime = time.Second * 10
expTime = time.Hour
}
// Create session