From 6ff84bbc1a4f83ae48d891410f1f69a968168c6c Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 13 Mar 2024 18:45:14 -0400 Subject: [PATCH] refactor: use dedicated auth mw for ping --- api/account/account.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/api/account/account.go b/api/account/account.go index ce8aadd..d9491b9 100644 --- a/api/account/account.go +++ b/api/account/account.go @@ -271,13 +271,6 @@ func (a AccountAPI) ping(jc jape.Context) { } func (a AccountAPI) Routes() (*httprouter.Router, error) { - authMw2fa := authMiddleware(middleware.AuthMiddlewareOptions{ - Identity: a.identity, - Accounts: a.accounts, - Config: a.config, - Purpose: account.JWTPurpose2FA, - }) - loginAuthMw2fa := authMiddleware(middleware.AuthMiddlewareOptions{ Identity: a.identity, Accounts: a.accounts, @@ -287,6 +280,13 @@ func (a AccountAPI) Routes() (*httprouter.Router, error) { }) authMw := authMiddleware(middleware.AuthMiddlewareOptions{ + Identity: a.identity, + Accounts: a.accounts, + Config: a.config, + Purpose: account.JWTPurposeNone, + }) + + pingAuthMw := authMiddleware(middleware.AuthMiddlewareOptions{ Identity: a.identity, Accounts: a.accounts, Config: a.config, @@ -294,7 +294,7 @@ func (a AccountAPI) Routes() (*httprouter.Router, error) { }) routes := map[string]jape.Handler{ - "POST /api/auth/ping": middleware.ApplyMiddlewares(a.ping, authMw2fa, middleware.ProxyMiddleware), + "POST /api/auth/ping": middleware.ApplyMiddlewares(a.ping, pingAuthMw, middleware.ProxyMiddleware), "POST /api/auth/login": middleware.ApplyMiddlewares(a.login, loginAuthMw2fa, middleware.ProxyMiddleware), "POST /api/auth/register": middleware.ApplyMiddlewares(a.register, middleware.ProxyMiddleware), "POST /api/auth/verify-email": middleware.ApplyMiddlewares(a.verifyEmail, middleware.ProxyMiddleware),