fix unauthenticated topic details flow
authorJustin Wind <justin.wind+git@gmail.com>
Sun, 15 May 2022 20:34:50 +0000 (13:34 -0700)
committerJustin Wind <justin.wind+git@gmail.com>
Sun, 15 May 2022 20:34:50 +0000 (13:34 -0700)
src/service.js
test/src/service.js

index 7e07a49ca489206d5fabeeb44a8f2b87c6ec7dfa..e76959978eddab7a554dbe80eb4d31ffa9c10d8a 100644 (file)
@@ -171,9 +171,9 @@ class Service extends Dingus {
 
     this.setResponseType(this.responseTypes, req, res, ctx);
 
-    await this.authenticator.sessionRequired(req, res, ctx, this.loginPath);
-
-    await this.manager.getAdminOverview(res, ctx);
+    if (await this.authenticator.sessionRequired(req, res, ctx, this.loginPath)) {
+      await this.manager.getAdminOverview(res, ctx);
+    }
   }
 
 
@@ -190,9 +190,9 @@ class Service extends Dingus {
 
     this.setResponseType(this.responseTypes, req, res, ctx);
 
-    await this.authenticator.sessionRequired(req, res, ctx, this.loginPath);
-
-    await this.manager.getTopicDetails(res, ctx);
+    if (await this.authenticator.sessionRequired(req, res, ctx, this.loginPath)) {
+      await this.manager.getTopicDetails(res, ctx);
+    }
   }
 
 
index 9afaf13d0242e839a433a969515d08c5884d726f..62c0059553a0cbce037a75909d01902063e9178d 100644 (file)
@@ -108,19 +108,33 @@ describe('Service', function () {
   }); // handlerGetHistorySVG
 
   describe('handlerGetAdminOverview', function () {
-    it('covers', async function () {
+    it('covers authenticated', async function () {
+      service.authenticator.sessionRequired.resolves(false);
+      await service.handlerGetAdminOverview(req, res, ctx);
+      assert(service.authenticator.sessionRequired.called);
+      assert(service.manager.getAdminOverview.notCalled);
+    });
+    it('covers unauthenticated', async function () {
+      service.authenticator.sessionRequired.resolves(true);
       await service.handlerGetAdminOverview(req, res, ctx);
       assert(service.authenticator.sessionRequired.called);
       assert(service.manager.getAdminOverview.called);
-    })
+    });
   }); // handlerGetAdminOverview
 
   describe('handlerGetAdminTopicDetails', function () {
-    it('covers', async function () {
+    it('covers unauthenticated', async function () {
+      service.authenticator.sessionRequired.resolves(false);
+      await service.handlerGetAdminTopicDetails(req, res, ctx);
+      assert(service.authenticator.sessionRequired.called);
+      assert(service.manager.getTopicDetails.notCalled);
+    });
+    it('covers authenticated', async function () {
+      service.authenticator.sessionRequired.resolves(true);
       await service.handlerGetAdminTopicDetails(req, res, ctx);
       assert(service.authenticator.sessionRequired.called);
       assert(service.manager.getTopicDetails.called);
-    })
+    });
   }); // handlerGetAdminTopicDetails
 
   describe('handlerPostAdminProcess', function () {