fix un-awaited cookie setting
[squeep-authentication-module] / lib / session-manager.js
index 6af1017ad6c1d6a5bdfc3c7ca53fdb3d72e239ca..43990cc376e4ee8b16a35092c2bf81620b3a1b9a 100644 (file)
@@ -23,8 +23,8 @@ class SessionManager {
    * @param {Number=} options.authenticator.inactiveSessionLifespanSeconds
    * @param {Boolean} options.authenticator.secureAuthOnly
    * @param {Object} options.dingus
-   * @param {Object} options.dingus.proxyPrefix
-   * @param {Object} options.dingus.selfBaseUrl
+   * @param {String} options.dingus.proxyPrefix
+   * @param {String} options.dingus.selfBaseUrl
    */
   constructor(logger, authenticator, options) {
     this.logger = logger;
@@ -140,13 +140,13 @@ class SessionManager {
     &&  me) {
       let profile;
       profile = await this.indieAuthCommunication.fetchProfile(me);
-      if ((!profile || !profile.metadata)
+      if ((!profile?.metadata)
       &&  meAutoScheme) {
         this.logger.debug(_scope, 'trying http fallback', { ctx });
         me.protocol = 'http';
         profile = await this.indieAuthCommunication.fetchProfile(me);
       }
-      if (!profile || !profile.metadata) {
+      if (!profile?.metadata) {
         this.logger.debug(_scope, 'failed to find any profile information at url', { ctx });
         ctx.errors.push(`No profile information was found at '${me}'.`);
       } else {
@@ -227,7 +227,7 @@ class SessionManager {
     const _scope = _fileScope('getAdminLogout');
     this.logger.debug(_scope, 'called', { ctx });
 
-    this._sessionCookieSet(res, '', 0);
+    await this._sessionCookieSet(res, '', 0);
 
     const redirect = ctx.queryParams['r'] || './';