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

Former-commit-id: b5987f2e8d
This commit is contained in:
Cheng Gu 2023-08-10 10:48:39 +08:00 committed by GitHub
parent 0cbe516ca3
commit d3dcb599ca

View file

@ -114,6 +114,16 @@ class AuthContext implements IAuthContext {
const r = await api.login(email, password, stayLoggedIn); const r = await api.login(email, password, stayLoggedIn);
if (!r.error) { 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._token.value = r.data.token;
this._expiresAt.value = r.data.expiresAt as string; this._expiresAt.value = r.data.expiresAt as string;
this._attachmentToken.value = r.data.attachmentToken; this._attachmentToken.value = r.data.attachmentToken;