feat: set cookies' expires attribute and fix remember me (#530)

This commit is contained in:
Cheng Gu 2023-08-10 10:48:39 +08:00 committed by GitHub
parent 2cbcc8bb1d
commit b5987f2e8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -114,6 +114,16 @@ class AuthContext implements IAuthContext {
const r = await api.login(email, password, stayLoggedIn);
if (!r.error) {
const expiresAt = new Date(r.data.expiresAt);
this._token = useCookie(AuthContext.cookieTokenKey, {
expires: expiresAt,
});
this._expiresAt = useCookie(AuthContext.cookieExpiresAtKey, {
expires: expiresAt,
});
this._attachmentToken = useCookie(AuthContext.cookieAttachmentTokenKey, {
expires: expiresAt,
});
this._token.value = r.data.token;
this._expiresAt.value = r.data.expiresAt as string;
this._attachmentToken.value = r.data.attachmentToken;