• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kiva / ui / 15721249898

18 Jun 2025 12:51AM UTC coverage: 52.564% (+4.7%) from 47.872%
15721249898

Pull #6091

github

web-flow
Merge 1f8983303 into e6c7ae52e
Pull Request #6091: feat: cacheable server-side rendering

1789 of 3594 branches covered (49.78%)

Branch coverage included in aggregate %.

276 of 398 new or added lines in 38 files covered. (69.35%)

7 existing lines in 4 files now uncovered.

2629 of 4811 relevant lines covered (54.65%)

280.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/api/Auth0Link.js
1
import { setContext } from '@apollo/client/link/context/index';
2

3
// Add the user info to the context and add the access token to the authorization header
4
function getAuthContext(context, user, token) {
5
        context.user = user;
×
6
        if (token) {
×
7
                context.headers = {
×
8
                        ...context.headers,
9
                        authorization: `Bearer ${token}`
10
                };
11
        }
12
        return context;
×
13
}
14

15
export default ({ kvAuth0 }) => {
16
        return setContext((operation, previousContext) => {
×
17
                // If no kvAuth0 object is passed, return the previous context
NEW
18
                if (!kvAuth0) return previousContext;
×
19

20
                // If auth0 is not enabled, don't add anything to the context
21
                if (!kvAuth0.enabled) return getAuthContext(previousContext);
×
22

23
                // If using fake authentication, just add fake auth headers to the context
24
                try {
×
25
                        const fakeAuthInfo = kvAuth0.getFakeAuthCookieValue();
×
26
                        if (fakeAuthInfo && kvAuth0.fakeAuthAllowed()) {
×
27
                                return {
×
28
                                        ...previousContext,
29
                                        headers: {
30
                                                ...previousContext.headers,
31
                                                'x-fa-user-id': fakeAuthInfo.userId,
32
                                                'x-fa-scopes': fakeAuthInfo.scopes.join(' '),
33
                                                'x-fa-app-id': kvAuth0.clientID || 'org.kiva.www',
×
34
                                        }
35
                                };
36
                        }
37
                } catch (e) {
38
                        console.error(e);
×
39
                }
40

41
                // If we already have user info, and we don't need to check login, just add that to the context
42
                if (kvAuth0.getKivaId() && !kvAuth0.getSyncCookieValue()) {
×
43
                        return getAuthContext(previousContext, kvAuth0.user, kvAuth0.accessToken);
×
44
                }
45

46
                // If user is supposed to be logged out, don't add anything to the context
47
                if (kvAuth0.isNotedLoggedOut()) {
×
48
                        return getAuthContext(previousContext);
×
49
                }
50

51
                // If the user's kiva id matches the id stored in the login sync cookie, add the user to the context
52
                if (kvAuth0.getKivaId() && kvAuth0.isNotedUserSessionUser()) {
×
53
                        return getAuthContext(previousContext, kvAuth0.user, kvAuth0.accessToken);
×
54
                }
55

56
                // Return previousContext if on a server process before checkSession block
57
                if (kvAuth0.isServer) return getAuthContext(previousContext);
×
58

59
                // Return previousContext if on a denied page
60
                const deniedPathList = [
×
61
                        '/error',
62
                        '/register/social',
63
                ];
64
                if (deniedPathList.indexOf(window.location.pathname) > -1) {
×
65
                        return getAuthContext(previousContext);
×
66
                }
67

68
                // Otherwise, check to see if the user has a session on Auth0 and then add that info to the context
69
                return new Promise((resolve, reject) => {
×
70
                        kvAuth0.checkSession().then(() => {
×
71
                                resolve(getAuthContext(previousContext, kvAuth0.user, kvAuth0.accessToken));
×
72
                        }).catch(reject);
73
                });
74
        });
75
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc