MCPcopy Index your code
hub / github.com/parse-community/parse-server / renewSessionIfNeeded

Function renewSessionIfNeeded

src/Auth.js:86–125  ·  view source on GitHub ↗
({ config, session, sessionToken })

Source from the content-addressed store, hash-verified

84}
85
86const renewSessionIfNeeded = async ({ config, session, sessionToken }) => {
87 if (!config?.extendSessionOnUse) {
88 return;
89 }
90 if (throttle.get(sessionToken)) {
91 return;
92 }
93 throttle.set(sessionToken, true);
94 try {
95 if (!session) {
96 const query = await RestQuery({
97 method: RestQuery.Method.get,
98 config,
99 auth: master(config),
100 runBeforeFind: false,
101 className: '_Session',
102 restWhere: { sessionToken },
103 restOptions: { limit: 1 },
104 });
105 const { results } = await query.execute();
106 session = results[0];
107 }
108
109 if (!shouldUpdateSessionExpiry(config, session) || !session) {
110 return;
111 }
112 const expiresAt = config.generateSessionExpiresAt();
113 await new RestWrite(
114 config,
115 master(config),
116 '_Session',
117 { objectId: session.objectId },
118 { expiresAt: Parse._encode(expiresAt) }
119 ).execute();
120 } catch (e) {
121 if (e?.code !== Parse.Error.OBJECT_NOT_FOUND) {
122 logger.error('Could not update session expiry: ', e);
123 }
124 }
125};
126
127// Returns a promise that resolves to an Auth object
128const getAuthForSessionToken = async function ({

Callers 1

getAuthForSessionTokenFunction · 0.85

Calls 7

RestQueryFunction · 0.85
masterFunction · 0.85
executeMethod · 0.80
errorMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected