Scheduling infrastructure for absolutely everyone.
fix: Refresh session (#10019)
Ansari98707e66e112
diff --git a/apps/web/components/ui/UsernameAvailability/PremiumTextfield.tsx b/apps/web/components/ui/UsernameAvailability/PremiumTextfield.tsxindex 950da969202..27182e2b5c0 100644--- a/apps/web/components/ui/UsernameAvailability/PremiumTextfield.tsx+++ b/apps/web/components/ui/UsernameAvailability/PremiumTextfield.tsx@@ -1,5 +1,6 @@import classNames from "classnames";import { debounce, noop } from "lodash";+import { useSession } from "next-auth/react";import { useRouter } from "next/router";import type { RefCallback } from "react";import { useEffect, useMemo, useState } from "react";@@ -46,6 +47,7 @@ const obtainNewUsernameChangeCondition = ({const PremiumTextfield = (props: ICustomUsernameProps) => {const { t } = useLocale();+ const { data: session, update } = useSession();const {currentUsername,setCurrentUsername = noop,@@ -94,6 +96,7 @@ const PremiumTextfield = (props: ICustomUsernameProps) => {const updateUsername = trpc.viewer.updateProfile.useMutation({onSuccess: async () => {onSuccessMutation && (await onSuccessMutation());+ await update();setOpenDialogSaveUsername(false);},onError: (error) => {diff --git a/apps/web/components/ui/UsernameAvailability/UsernameTextfield.tsx b/apps/web/components/ui/UsernameAvailability/UsernameTextfield.tsxindex 05871030c78..dd0c3d84565 100644--- a/apps/web/components/ui/UsernameAvailability/UsernameTextfield.tsx+++ b/apps/web/components/ui/UsernameAvailability/UsernameTextfield.tsx@@ -1,5 +1,6 @@import classNames from "classnames";import { debounce, noop } from "lodash";+import { useSession } from "next-auth/react";import type { RefCallback } from "react";import { useEffect, useMemo, useState } from "react";@@ -23,6 +24,7 @@ interface ICustomUsernameProps {const UsernameTextfield = (props: ICustomUsernameProps & Partial<React.ComponentProps<typeof TextField>>) => {const { t } = useLocale();+ const { data: session, update } = useSession();const {currentUsername,setCurrentUsername = noop,@@ -69,6 +71,7 @@ const UsernameTextfield = (props: ICustomUsernameProps & Partial<React.ComponentonSuccessMutation && (await onSuccessMutation());setOpenDialogSaveUsername(false);setCurrentUsername(inputUsernameValue);+ await update();},onError: (error) => {onErrorMutation && onErrorMutation(error);diff --git a/apps/web/package.json b/apps/web/package.jsonindex 68172376719..e46a2199e7a 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -89,7 +89,7 @@"micro": "^10.0.1","mime-types": "^2.1.35","next": "^13.4.6",- "next-auth": "^4.20.1",+ "next-auth": "^4.22.1","next-axiom": "^0.17.0","next-collect": "^0.2.1","next-i18next": "^13.2.2",diff --git a/packages/features/auth/lib/next-auth-options.ts b/packages/features/auth/lib/next-auth-options.tsindex 00b6ac53336..4a496fd7a94 100644--- a/packages/features/auth/lib/next-auth-options.ts+++ b/packages/features/auth/lib/next-auth-options.ts@@ -349,7 +349,7 @@ export const AUTH_OPTIONS: AuthOptions = {},providers,callbacks: {- async jwt({ token, user, account }) {+ async jwt({ token, user, account, trigger, session }) {const autoMergeIdentities = async () => {const existingUser = await prisma.user.findFirst({// eslint-disable-next-line @typescript-eslint/no-non-null-assertiondiff --git a/packages/features/auth/package.json b/packages/features/auth/package.jsonindex 5948ed54b81..9f451d57097 100644--- a/packages/features/auth/package.json+++ b/packages/features/auth/package.json@@ -16,7 +16,7 @@"handlebars": "^4.7.7","jose": "^4.13.1","lru-cache": "^9.0.3",- "next-auth": "^4.20.1",+ "next-auth": "^4.22.1","nodemailer": "^6.7.8","otplib": "^12.0.1"}