web-installer/src/server.js
// This function retrieves the refresh token from the database
This function retrieves the refresh token from the database
This function retrieves the refresh token from the database
async function retrieveRefreshToken(username) {
  let client;
  let db;
  try {
    client = await mongoClient.connect(mongoDBUrl, mongo.options);
    db = client.db(dbname);
    const collection = db.collection(instAuthCollection);
    const record = await collection.findOne({ username });
    if (!record) {
      return '';
    }
    return record.refreshToken;
  } catch (err) {
    throw new errors.MongoError(err.message);
  } finally {
    if (client && client.isConnected()) {
      await client.close();
    }
  }
}
async function retrieveRefreshToken ( username ) { let client ; let db ; try { client = await mongoClient . connect ( mongoDBUrl , mongo . options ) ; db = client . db ( dbname ) ; const collection = db . collection ( instAuthCollection ) ; const record = await collection . findOne ( { username } ) ; if ( ! record ) { return '' ; } return record . refreshToken ; } catch ( err ) { throw new errors . MongoError ( err . message ) ; } finally { if ( client && client . isConnected ( ) ) { await client . close ( ) ; } } }
This function retrieves the refresh token from the database
This function retrieves the refresh token from the database
// connect // Find the authentication document // If the username is not found, return and empty string // Otherwise return the refresh token of the record. // If an error is raised throw a MongoError // Check if an error was thrown after a connection was established. If this // is the case close the database connection to prevent leaks