mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
chore: ensureConfigured is now async
This commit is contained in:
@@ -156,7 +156,7 @@ const middleware = async (req, res, next) => {
|
||||
throw new Error(`Unexpected OAuth service ${serviceName}`);
|
||||
|
||||
// Make sure we're configured
|
||||
ensureConfigured(serviceName);
|
||||
await ensureConfigured(serviceName);
|
||||
|
||||
const handler = OAuth._requestHandlers[service.version];
|
||||
if (!handler)
|
||||
@@ -167,7 +167,6 @@ const middleware = async (req, res, next) => {
|
||||
} else {
|
||||
requestData = req.body;
|
||||
}
|
||||
|
||||
await handler(service, requestData, res);
|
||||
} catch (err) {
|
||||
// if we got thrown an error, save it off, it will get passed to
|
||||
@@ -179,7 +178,7 @@ const middleware = async (req, res, next) => {
|
||||
// style the error or react to it in any way.
|
||||
if (requestData?.state && err instanceof Error) {
|
||||
try { // catch any exceptions to avoid crashing runner
|
||||
OAuth._storePendingCredential(OAuth._credentialTokenFromQuery(requestData), err);
|
||||
await OAuth._storePendingCredential(OAuth._credentialTokenFromQuery(requestData), err);
|
||||
} catch (err) {
|
||||
// Ignore the error and just give up. If we failed to store the
|
||||
// error, then the login will just fail with a generic error.
|
||||
@@ -193,7 +192,7 @@ const middleware = async (req, res, next) => {
|
||||
// think to check server logs (we hope?)
|
||||
// Catch errors because any exception here will crash the runner.
|
||||
try {
|
||||
OAuth._endOfLoginResponse(res, {
|
||||
await OAuth._endOfLoginResponse(res, {
|
||||
query: requestData,
|
||||
loginStyle: OAuth._loginStyleFromQuery(requestData),
|
||||
error: err
|
||||
@@ -237,11 +236,14 @@ const oauthServiceName = req => {
|
||||
};
|
||||
|
||||
// Make sure we're configured
|
||||
const ensureConfigured = serviceName => {
|
||||
if (!ServiceConfiguration.configurations.findOne({service: serviceName})) {
|
||||
throw new ServiceConfiguration.ConfigError();
|
||||
}
|
||||
};
|
||||
const ensureConfigured =
|
||||
async serviceName => {
|
||||
const config =
|
||||
await ServiceConfiguration.configurations.findOne({ service: serviceName })
|
||||
if (!config) {
|
||||
throw new ServiceConfiguration.ConfigError();
|
||||
}
|
||||
};
|
||||
|
||||
const isSafe = value => {
|
||||
// This matches strings generated by `Random.secret` and
|
||||
|
||||
Reference in New Issue
Block a user