feat(SW-307): User logout after password update
This commit is contained in:
@@ -8,6 +8,7 @@ import { usePhoneInput } from "react-international-phone"
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import { type Lang, langToApiLang } from "@/constants/languages"
|
||||
import { logout } from "@/constants/routes/handleAuth"
|
||||
import { profile } from "@/constants/routes/myPages"
|
||||
import { trpc } from "@/lib/trpc/client"
|
||||
|
||||
@@ -74,6 +75,7 @@ export default function Form({ user }: EditFormProps) {
|
||||
const trigger = methods.trigger
|
||||
|
||||
async function handleSubmit(data: EditProfileSchema) {
|
||||
const isPasswordChanged = !!data.newPassword
|
||||
const response = await editProfile(data)
|
||||
switch (response.status) {
|
||||
case Status.error:
|
||||
@@ -87,7 +89,11 @@ export default function Form({ user }: EditFormProps) {
|
||||
case Status.success:
|
||||
toast.success(response.message)
|
||||
utils.user.get.invalidate()
|
||||
router.push(profile[lang])
|
||||
if (isPasswordChanged) {
|
||||
router.push(logout[lang] + "?redirectTo=%2Flogin%3Fuppd%3D1")
|
||||
} else {
|
||||
router.push(profile[lang])
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user