Skip to content

Commit

Permalink
hotfix: fixes session duration from go-shiori#346
Browse files Browse the repository at this point in the history
  • Loading branch information
fmartingr committed Feb 11, 2022
1 parent 2dc462b commit 2ca628b
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 104 deletions.
16 changes: 9 additions & 7 deletions internal/view/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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";
Expand All @@ -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}`;

Expand Down
Loading

0 comments on commit 2ca628b

Please sign in to comment.