Add temporary client-side auth logging
This commit is contained in:
parent
2b692754ec
commit
5180fd7ea6
@ -9,6 +9,7 @@ import {
|
||||
signOut,
|
||||
} from '@/auth';
|
||||
import { PATH_ADMIN_PHOTOS, PATH_ROOT } from '@/site/paths';
|
||||
import type { Session } from 'next-auth';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
export const signInAction = async (
|
||||
@ -40,3 +41,6 @@ export const signOutAndRedirectAction = async () =>
|
||||
signOut({ redirectTo: PATH_ROOT });
|
||||
|
||||
export const getAuthAction = () => auth();
|
||||
|
||||
export const logClientAuthUpdate = (data: Session | null | undefined) =>
|
||||
console.log('Client auth update', data);
|
||||
|
||||
@ -4,7 +4,7 @@ import { useState, useEffect, ReactNode, useCallback } from 'react';
|
||||
import { AppStateContext } from './AppState';
|
||||
import { AnimationConfig } from '@/components/AnimateItems';
|
||||
import usePathnames from '@/utility/usePathnames';
|
||||
import { getAuthAction } from '@/auth/actions';
|
||||
import { getAuthAction, logClientAuthUpdate } from '@/auth/actions';
|
||||
import useSWR from 'swr';
|
||||
import { MATTE_PHOTOS } from '@/site/config';
|
||||
|
||||
@ -38,7 +38,10 @@ export default function AppStateProvider({
|
||||
const invalidateSwr = useCallback(() => setSwrTimestamp(Date.now()), []);
|
||||
|
||||
const { data } = useSWR('getAuth', getAuthAction);
|
||||
useEffect(() => setUserEmail(data?.user?.email ?? undefined), [data]);
|
||||
useEffect(() => {
|
||||
setUserEmail(data?.user?.email ?? undefined);
|
||||
logClientAuthUpdate(data);
|
||||
}, [data]);
|
||||
|
||||
const registerAdminUpdate = useCallback(() =>
|
||||
setAdminUpdateTimes(updates => [...updates, new Date()])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user