mirror of
https://github.com/go-shiori/shiori.git
synced 2025-09-10 23:15:55 +08:00
hotfix: fixes session duration from #346
This commit is contained in:
parent
2dc462b010
commit
2ca628b7fe
3 changed files with 106 additions and 104 deletions
|
@ -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
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue