Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

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

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions frontend/composables/use-auth-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down