fix: Refresh session (#10019)

* Refresh session 🔄

* Update apps/web/components/ui/UsernameAvailability/PremiumTextfield.tsx

Co-authored-by: Omar López <zomars@me.com>

* Update apps/web/components/ui/UsernameAvailability/UsernameTextfield.tsx

Co-authored-by: Omar López <zomars@me.com>

* Update packages/features/auth/lib/next-auth-options.ts

Co-authored-by: Omar López <zomars@me.com>

---------

Co-authored-by: Ansari <thameem.ns@zohocorp.com>
Co-authored-by: Shivam Kalra <shivamkalra98@gmail.com>
Co-authored-by: Omar López <zomars@me.com>
This commit is contained in:
Ansari
2023-07-13 14:21:28 +02:00
committed by GitHub
co-authored by Omar López Ansari Shivam Kalra
parent 44308cbfa0
commit 98707e66e1
5 changed files with 9 additions and 3 deletions
@@ -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) => {
@@ -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.Component
onSuccessMutation && (await onSuccessMutation());
setOpenDialogSaveUsername(false);
setCurrentUsername(inputUsernameValue);
await update();
},
onError: (error) => {
onErrorMutation && onErrorMutation(error);
+1 -1
View File
@@ -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",
@@ -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-assertion
+1 -1
View File
@@ -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"
}