@omerlo/omerlo-webkit 0.0.35 → 0.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -51,7 +51,7 @@ export interface MediaSectionSummary {
|
|
|
51
51
|
updatedAt: Date;
|
|
52
52
|
}
|
|
53
53
|
export interface MediaSectionHierarchy extends MediaSectionSummary {
|
|
54
|
-
sections:
|
|
54
|
+
sections: MediaSectionHierarchy[];
|
|
55
55
|
}
|
|
56
56
|
export interface MediaSection extends MediaSectionSummary {
|
|
57
57
|
description: string | null;
|
|
@@ -22,7 +22,7 @@ const accessTokenCookieName = 'access_token';
|
|
|
22
22
|
const refreshTokenCookieName = 'refresh_token';
|
|
23
23
|
const THREE_MONTH = 90 * 24 * 60 * 60;
|
|
24
24
|
export function setAuthorizationCookies(cookies, token) {
|
|
25
|
-
cookies.set('logged_in', 'true', { path: '/', httpOnly: false });
|
|
25
|
+
cookies.set('logged_in', 'true', { path: '/', httpOnly: false, maxAge: THREE_MONTH });
|
|
26
26
|
cookies.set(accessTokenCookieName, token.accessToken, {
|
|
27
27
|
httpOnly: true,
|
|
28
28
|
path: '/',
|
|
@@ -31,25 +31,23 @@ export function initUserSession(session) {
|
|
|
31
31
|
throw new Error('MUST NOT call refresh on user session from server side.');
|
|
32
32
|
}
|
|
33
33
|
invalidate('omerlo:user_session');
|
|
34
|
-
update(updateUserInfo(null, false));
|
|
34
|
+
update(updateUserInfo(null, false, false));
|
|
35
35
|
},
|
|
36
36
|
refresh: async () => {
|
|
37
37
|
if (!browser) {
|
|
38
38
|
throw new Error('MUST NOT call refresh on user session from server side.');
|
|
39
39
|
}
|
|
40
|
-
const userInfo = await useReader(fetch)
|
|
41
|
-
|
|
42
|
-
.then((resp) => resp.data);
|
|
43
|
-
update(updateUserInfo(userInfo, true));
|
|
40
|
+
const userInfo = await useReader(fetch).userInfo();
|
|
41
|
+
update(updateUserInfo(userInfo.data, true, userInfo.ok));
|
|
44
42
|
}
|
|
45
43
|
};
|
|
46
44
|
setContext('user_session', ctx);
|
|
47
45
|
return ctx;
|
|
48
46
|
}
|
|
49
|
-
const updateUserInfo = (userInfo, authenticated) => {
|
|
47
|
+
const updateUserInfo = (userInfo, authenticated, verified) => {
|
|
50
48
|
return (session) => {
|
|
51
49
|
session.user = userInfo;
|
|
52
|
-
session.verified =
|
|
50
|
+
session.verified = verified;
|
|
53
51
|
session.authenticated = authenticated;
|
|
54
52
|
localStorage.setItem('user_session', JSON.stringify(session));
|
|
55
53
|
return session;
|