refactor: clarify frontend module ownership
This commit is contained in:
@@ -31,6 +31,7 @@ function useAuthProviderVm() {
|
||||
const [user, setUser] = useState<undefined | User>(undefined);
|
||||
const accessTokenRef = useRef<string | undefined>(undefined);
|
||||
const [ready, setReady] = useState(false);
|
||||
const [signedOut, setSignedOut] = useState(false);
|
||||
|
||||
const generationRef = useRef(0);
|
||||
const userRef = useRef<undefined | User>(undefined);
|
||||
@@ -57,6 +58,7 @@ function useAuthProviderVm() {
|
||||
const changedIdentity
|
||||
= userRef.current && userRef.current.id !== authentication.user.id;
|
||||
|
||||
setSignedOut(false);
|
||||
accessTokenRef.current = authentication.accessToken;
|
||||
|
||||
if (changedIdentity) {
|
||||
@@ -136,6 +138,7 @@ function useAuthProviderVm() {
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
setSignedOut(true);
|
||||
clearSession();
|
||||
await serialize(async () => {
|
||||
await apiClient.POST("/api/v1/auth/logout");
|
||||
@@ -159,6 +162,7 @@ function useAuthProviderVm() {
|
||||
ready,
|
||||
register: (email: string, password: string) =>
|
||||
authenticate("/api/v1/auth/register", email, password),
|
||||
signedOut,
|
||||
user,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user