From 01a85791583cdb3d11f1d968cffbbf1c1ff68b1d Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 19 Jul 2023 11:30:11 -0400 Subject: [PATCH] minor fix --- components/Modal/User/ChangePassword.tsx | 26 ++++++++++++----------- components/Modal/User/ProfileSettings.tsx | 1 - 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/components/Modal/User/ChangePassword.tsx b/components/Modal/User/ChangePassword.tsx index 6237291..09e0f3b 100644 --- a/components/Modal/User/ChangePassword.tsx +++ b/components/Modal/User/ChangePassword.tsx @@ -1,7 +1,7 @@ import { Dispatch, SetStateAction, useEffect, useState } from "react"; import { AccountSettings } from "@/types/global"; import useAccountStore from "@/store/account"; -import { useSession } from "next-auth/react"; +import { signOut, useSession } from "next-auth/react"; import { faPenToSquare } from "@fortawesome/free-regular-svg-icons"; import SubmitButton from "@/components/SubmitButton"; import { toast } from "react-hot-toast"; @@ -50,22 +50,24 @@ export default function ChangePassword({ if (response.ok) { toast.success("Settings Applied!"); - togglePasswordFormModal(); - } else toast.error(response.data as string); - setSubmitLoader(false); + if ( + user.username !== account.username || + user.name !== account.name || + user.email !== account.email + ) { + update({ + username: user.username, + email: user.username, + name: user.name, + }); - if ( - (user.username !== account.username || user.name !== account.name) && - user.username && - user.email - ) - update({ username: user.username, name: user.name }); + signOut(); + } - if (response.ok) { setUser({ ...user, newPassword: undefined }); togglePasswordFormModal(); - } + } else toast.error(response.data as string); } else { toast.error("Passwords do not match."); } diff --git a/components/Modal/User/ProfileSettings.tsx b/components/Modal/User/ProfileSettings.tsx index 3db24b6..5090846 100644 --- a/components/Modal/User/ProfileSettings.tsx +++ b/components/Modal/User/ProfileSettings.tsx @@ -77,7 +77,6 @@ export default function ProfileSettings({ if (response.ok) { toast.success("Settings Applied!"); - toggleSettingsModal(); if ( user.username !== account.username ||