mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
SecurityManager: Don't prefetch values
Prefetching can cause unhandled Promise rejections, and it makes the code less readable.
This commit is contained in:
parent
8053875d45
commit
b89ae69202
1 changed files with 3 additions and 8 deletions
|
@ -95,18 +95,13 @@ exports.checkAccess = async (padID, sessionCookie, token, userSettings) => {
|
||||||
return DENY;
|
return DENY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// start fetching the info we may need
|
const padExists = await padManager.doesPadExist(padID);
|
||||||
const p_sessionAuthorID = sessionManager.findAuthorID(padID.split('$')[0], sessionCookie);
|
|
||||||
const p_tokenAuthorID = authorManager.getAuthor4Token(token);
|
|
||||||
const p_padExists = padManager.doesPadExist(padID);
|
|
||||||
|
|
||||||
const padExists = await p_padExists;
|
|
||||||
if (!padExists && !canCreate) {
|
if (!padExists && !canCreate) {
|
||||||
authLogger.debug('access denied: user attempted to create a pad, which is prohibited');
|
authLogger.debug('access denied: user attempted to create a pad, which is prohibited');
|
||||||
return DENY;
|
return DENY;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sessionAuthorID = await p_sessionAuthorID;
|
const sessionAuthorID = await sessionManager.findAuthorID(padID.split('$')[0], sessionCookie);
|
||||||
if (settings.requireSession && !sessionAuthorID) {
|
if (settings.requireSession && !sessionAuthorID) {
|
||||||
authLogger.debug('access denied: HTTP API session is required');
|
authLogger.debug('access denied: HTTP API session is required');
|
||||||
return DENY;
|
return DENY;
|
||||||
|
@ -114,7 +109,7 @@ exports.checkAccess = async (padID, sessionCookie, token, userSettings) => {
|
||||||
|
|
||||||
const grant = {
|
const grant = {
|
||||||
accessStatus: 'grant',
|
accessStatus: 'grant',
|
||||||
authorID: (sessionAuthorID != null) ? sessionAuthorID : await p_tokenAuthorID,
|
authorID: sessionAuthorID || await authorManager.getAuthor4Token(token),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!padID.includes('$')) {
|
if (!padID.includes('$')) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue