feat: returns queried user alongside refreshed token (#2813)
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
This commit is contained in:
28
test/auth/ui/AuthDebug.tsx
Normal file
28
test/auth/ui/AuthDebug.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useAuth } from '../../../src/admin/components/utilities/Auth';
|
||||
import { UIField } from '../../../src/fields/config/types';
|
||||
import { User } from '../../../src/auth';
|
||||
|
||||
export const AuthDebug: React.FC<UIField> = () => {
|
||||
const [state, setState] = useState<User | null | undefined>();
|
||||
const { user } = useAuth();
|
||||
|
||||
useEffect(() => {
|
||||
if (user) {
|
||||
fetch(`/api/users/${user.id}`).then((r) => r.json()).then((newUser) => {
|
||||
setState(newUser);
|
||||
});
|
||||
}
|
||||
}, [user]);
|
||||
|
||||
return (
|
||||
<div id="auth-debug-ui-field">
|
||||
<div id="users-api-result">
|
||||
{state?.custom as string}
|
||||
</div>
|
||||
<div id="use-auth-result">
|
||||
{user?.custom as string}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user