Skip to content

Commit

Permalink
Merge branch 'develop' into ryan/update-prettier-tailwind-plugin-and-…
Browse files Browse the repository at this point in the history
…run-on-codebase
  • Loading branch information
ryandotfurrer authored Jul 19, 2024
2 parents 68c968f + 229f2db commit 0d3dc84
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion context/AuthContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { DataStore } from '@/store/dataStore';
import { IUser } from '@/api/apiFunctions.interface';
import { getCurrentUser } from '@/api/apiFunctions';
import { loginAccount } from './AuthHelper';
import { usePathname } from 'next/navigation';

type UserCredentials = {
email: string;
Expand Down Expand Up @@ -43,6 +44,7 @@ export const AuthContextProvider = ({
(state) => state,
);
const router = useRouter();
const pathname = usePathname();

useEffect(() => {
if (user.id === '' || user.email === '') {
Expand Down Expand Up @@ -87,7 +89,9 @@ export const AuthContextProvider = ({
*/
const getUser = async (): Promise<IUser | undefined> => {
if (!isSessionInLocalStorage()) {
router.push('/login');
if (pathname !== '/register') {
router.push('/login');
}
return;
}

Expand Down

0 comments on commit 0d3dc84

Please sign in to comment.