fix: login and signup orgslug missing bug

This commit is contained in:
swve 2024-11-28 21:47:41 +01:00
parent 2e618d9c5a
commit f4794ebaf2
5 changed files with 15 additions and 14 deletions

View file

@ -4,6 +4,8 @@ import { useLHSession } from '@components/Contexts/LHSessionContext';
import useAdminStatus from '@components/Hooks/useAdminStatus';
import { usePathname, useRouter } from 'next/navigation';
import PageLoading from '@components/Objects/Loaders/PageLoading';
import { getUriWithoutOrg } from '@services/config/config';
import { useOrg } from '@components/Contexts/OrgContext';
type AuthorizationProps = {
children: React.ReactNode;
@ -22,6 +24,7 @@ const ADMIN_PATHS = [
const AdminAuthorization: React.FC<AuthorizationProps> = ({ children, authorizationMode }) => {
const session = useLHSession() as any;
const org = useOrg() as any;
const pathname = usePathname();
const router = useRouter();
const { isAdmin, loading } = useAdminStatus() as any
@ -51,7 +54,7 @@ const AdminAuthorization: React.FC<AuthorizationProps> = ({ children, authorizat
}
if (!isUserAuthenticated) {
router.push('/login');
router.push(getUriWithoutOrg('/login?orgslug=' + org.slug));
return;
}

View file

@ -25,10 +25,10 @@ export const HeaderProfileBox = () => {
<ul className="flex space-x-3 items-center">
<li>
<Link
href={{ pathname: getUriWithoutOrg('/login'), query: org ? { orgslug: org.slug } : null }} >Login</Link>
href={{ pathname: getUriWithoutOrg('/login?orgslug=' + org.slug), query: org ? { orgslug: org.slug } : null }} >Login</Link>
</li>
<li className="bg-black rounded-lg shadow-md p-2 px-3 text-white">
<Link href={{ pathname: getUriWithoutOrg('/signup'), query: org ? { orgslug: org.slug } : null }}>Sign up</Link>
<Link href={{ pathname: getUriWithoutOrg('/signup?orgslug=' + org.slug), query: org ? { orgslug: org.slug } : null }}>Sign up</Link>
</li>
</ul>
</UnidentifiedArea>