From b93acf85962859dad66c8754c1bcbe48eaf7b092 Mon Sep 17 00:00:00 2001 From: Fernando Chavez Date: Thu, 5 Sep 2024 14:48:51 +0200 Subject: [PATCH] fix(admin): fix authPage logic --- .../core/admin/admin/src/pages/Auth/AuthPage.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/core/admin/admin/src/pages/Auth/AuthPage.tsx b/packages/core/admin/admin/src/pages/Auth/AuthPage.tsx index 0079c53575..69d3630d2d 100644 --- a/packages/core/admin/admin/src/pages/Auth/AuthPage.tsx +++ b/packages/core/admin/admin/src/pages/Auth/AuthPage.tsx @@ -44,10 +44,18 @@ const AuthPage = () => { const Component = forms[authType as keyof FormDictionary]; // Redirect the user to the login page if - // the endpoint does not exist or + // the endpoint does not exists + if (!Component) { + return ; + } + + // User is already logged in + if (authType !== 'register-admin' && authType !== 'register' && token) { + return ; + } + // there is already an admin user oo - // the user is already logged in - if (!Component || (hasAdmin && authType === 'register-admin' && token)) { + if (hasAdmin && authType === 'register-admin' && token) { return ; }