From cbf6ac0ff9e0bbbaabb38a1cdc63017b254bac17 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 19 Apr 2023 13:04:24 -0400 Subject: [PATCH] refactor(striker-ui-api): rename authenticationHandler->guardApi --- striker-ui-api/src/app.ts | 4 ++-- striker-ui-api/src/lib/assertAuthentication.ts | 2 +- striker-ui-api/src/routes/auth.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/striker-ui-api/src/app.ts b/striker-ui-api/src/app.ts index 38d7f790..0bd58474 100644 --- a/striker-ui-api/src/app.ts +++ b/striker-ui-api/src/app.ts @@ -1,7 +1,7 @@ import cors from 'cors'; import express, { json } from 'express'; -import { authenticationHandler } from './lib/assertAuthentication'; +import { guardApi } from './lib/assertAuthentication'; import passport from './passport'; import routes from './routes'; import { rrouters } from './lib/rrouters'; @@ -21,7 +21,7 @@ app.use(passport.initialize()); app.use(passport.authenticate('session')); rrouters(app, routes.private, { - assign: (router) => [authenticationHandler, router], + assign: (router) => [guardApi, router], route: '/api', }); rrouters(app, routes.public, { route: '/api' }); diff --git a/striker-ui-api/src/lib/assertAuthentication.ts b/striker-ui-api/src/lib/assertAuthentication.ts index 96db0023..4abfb58f 100644 --- a/striker-ui-api/src/lib/assertAuthentication.ts +++ b/striker-ui-api/src/lib/assertAuthentication.ts @@ -36,4 +36,4 @@ export const assertAuthentication: (options?: { }; }; -export const authenticationHandler = assertAuthentication(); +export const guardApi = assertAuthentication(); diff --git a/striker-ui-api/src/routes/auth.ts b/striker-ui-api/src/routes/auth.ts index 1a2af236..5ffb8491 100644 --- a/striker-ui-api/src/routes/auth.ts +++ b/striker-ui-api/src/routes/auth.ts @@ -1,6 +1,6 @@ import express from 'express'; -import { authenticationHandler } from '../lib/assertAuthentication'; +import { guardApi } from '../lib/assertAuthentication'; import { login, logout } from '../lib/request_handlers/auth'; import passport from '../passport'; @@ -8,6 +8,6 @@ const router = express.Router(); router .post('/login', passport.authenticate('login'), login) - .put('/logout', authenticationHandler, logout); + .put('/logout', guardApi, logout); export default router;