Skip to content

Scheduling infrastructure for absolutely everyone.

fix: unauthorized after email change (#10821)

Udit Takkar5d491e0a126e
diff --git a/apps/web/pages/settings/my-account/profile.tsx b/apps/web/pages/settings/my-account/profile.tsx
index 294d615c46f..beaf694b1cb 100644
--- a/apps/web/pages/settings/my-account/profile.tsx
+++ b/apps/web/pages/settings/my-account/profile.tsx
@@ -82,21 +82,20 @@ const ProfileView = () => {
const { data: user, isLoading } = trpc.viewer.me.useQuery();
const updateProfileMutation = trpc.viewer.updateProfile.useMutation({
onSuccess: async (res) => {
+ await update(res);
showToast(t("settings_updated_successfully"), "success");
- if (res.signOutUser && tempFormValues) {
- if (res.passwordReset) {
- showToast(t("password_reset_email", { email: tempFormValues.email }), "success");
- // sign out the user to avoid unauthorized access error
- await signOut({ callbackUrl: "/auth/logout?passReset=true" });
- } else {
- // sign out the user to avoid unauthorized access error
- await signOut({ callbackUrl: "/auth/logout?emailChange=true" });
- }
+
+ // signout user only in case of password reset
+ if (res.signOutUser && tempFormValues && res.passwordReset) {
+ showToast(t("password_reset_email", { email: tempFormValues.email }), "success");
+ await signOut({ callbackUrl: "/auth/logout?passReset=true" });
+ } else {
+ utils.viewer.me.invalidate();
+ utils.viewer.avatar.invalidate();
+ utils.viewer.shouldVerifyEmail.invalidate();
}
- utils.viewer.me.invalidate();
- utils.viewer.avatar.invalidate();
+
setConfirmAuthEmailChangeWarningDialogOpen(false);
- update(res);
setTempFormValues(null);
},
onError: () => {
@@ -325,7 +324,10 @@ const ProfileView = () => {
{confirmPasswordErrorMessage && <Alert severity="error" title={confirmPasswordErrorMessage} />}
</div>
<DialogFooter showDivider>
- <Button color="primary" onClick={(e) => onConfirmPassword(e)}>
+ <Button
+ color="primary"
+ loading={confirmPasswordMutation.isLoading}
+ onClick={(e) => onConfirmPassword(e)}>
{t("confirm")}
</Button>
<DialogClose />
@@ -345,7 +347,7 @@ const ProfileView = () => {
<DialogFooter>
<Button
color="primary"
- disabled={updateProfileMutation.isLoading}
+ loading={updateProfileMutation.isLoading}
onClick={(e) => onConfirmAuthEmailChange(e)}>
{t("confirm")}
</Button>