From 1602cff06e13bb03e5c48e8369abf5c803426e4d Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Mon, 30 Oct 2023 09:53:40 +0700
Subject: Add set auth on authenticated

---
 src-migrate/modules/account-activation/components/FormToken.tsx | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

(limited to 'src-migrate/modules/account-activation/components/FormToken.tsx')

diff --git a/src-migrate/modules/account-activation/components/FormToken.tsx b/src-migrate/modules/account-activation/components/FormToken.tsx
index 6af24413..a1525fe6 100644
--- a/src-migrate/modules/account-activation/components/FormToken.tsx
+++ b/src-migrate/modules/account-activation/components/FormToken.tsx
@@ -7,6 +7,7 @@ import { useMutation } from "react-query"
 import Modal from "~/common/components/elements/Modal"
 import { ActivationTokenProps } from "~/common/types/auth"
 import { activationUserToken } from "~/services/auth"
+import { setAuth } from "~/common/libs/auth"
 
 const FormToken = () => {
   const { query } = useRouter()
@@ -24,7 +25,11 @@ const FormToken = () => {
     //eslint-disable-next-line
   }, [query.activation, query.token])
 
-  // TODO: Save user to local storage
+  useEffect(() => {
+    if (mutation.data?.user) {
+      setAuth(mutation.data.user)
+    }
+  }, [mutation.data])
 
   return (
     <Modal active={active} mode="desktop">
-- 
cgit v1.2.3

