commit d822a31794db149a14e074388fbab1a056df1204
parent 727c655cc73ce9fd809b4ce0e35d26010026e6fc
Author: Andreas Gruhler <andreas.gruhler@adfinis.com>
Date: Wed, 18 Sep 2024 22:24:43 +0200
fix(magic): cookie name and sameSite
Diffstat:
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/AuthVerify.jsx b/src/AuthVerify.jsx
@@ -7,17 +7,15 @@ const session_ttl = import.meta.env.VITE_SESSION_TTL
function AuthVerify() {
const [loading, setLoading] = useState(true)
- const [session, setSession, removeSession] = useCookies(['user'])
- const [response, setResponse] = useState({})
+ const [session, setSession, removeSession] = useCookies(['auth'])
const queryParameters = new URLSearchParams(window.location.search)
const token = queryParameters.get("token")
useEffect(() => {
(async () => {
- // check token validity on API endpoint
+ // check token validity on API endpoint
const response = await fetch(`${api_uri}:${api_port}/v1/auth/verify?token=${token}`)
const { message, data, error } = await response.json()
- setResponse(data)
if (error) {
alert(error)
@@ -25,6 +23,7 @@ function AuthVerify() {
// Set client session (https://www.npmjs.com/package/react-cookie)
setSession('auth', data, {
path: '/',
+ sameSite: true,
secure: process.env.NODE_ENV !== 'development',
maxAge: parseInt(session_ttl),
})