Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sweepstake
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Arjun Jhukal
sweepstake
Commits
a1188f74
Commit
a1188f74
authored
Mar 12, 2026
by
Arjun Jhukal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made the server and client private component similar
parent
ff982c05
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
18 additions
and
29 deletions
+18
-29
layout.tsx
src/app/(dashboard)/(user)/(privateUser)/layout.tsx
+0
-1
index.tsx
src/components/pages/auth/login/index.tsx
+5
-0
CoinCalculator.tsx
...erDashboard/buyCoins/buyCoinSinlgeGame/CoinCalculator.tsx
+2
-2
index.tsx
...erDashboard/buyCoins/buyCoinSinlgeGame/checkout/index.tsx
+2
-12
ReduxHydrator.tsx
src/routes/ReduxHydrator.tsx
+4
-2
ServerPrivate.tsx
src/routes/ServerPrivate.tsx
+4
-12
authSlice.ts
src/slice/authSlice.ts
+1
-0
No files found.
src/app/(dashboard)/(user)/(privateUser)/layout.tsx
View file @
a1188f74
...
...
@@ -5,7 +5,6 @@ import React from 'react'
export
default
function
PrivateUserLayout
({
children
}:
{
children
:
React
.
ReactNode
})
{
return
(
<
ServerPrivate
>
<
DashboardLayout
>
{
children
}
</
DashboardLayout
>
...
...
src/components/pages/auth/login/index.tsx
View file @
a1188f74
...
...
@@ -73,6 +73,11 @@ export default function LoginPage() {
secure
:
process
.
env
.
NODE_ENV
===
'production'
,
sameSite
:
'Strict'
,
});
Cookies
.
set
(
'user'
,
JSON
.
stringify
(
response
?.
data
?.
user
),
{
expires
:
1
,
secure
:
process
.
env
.
NODE_ENV
===
'production'
,
sameSite
:
'Strict'
,
});
router
.
replace
(
PATH
.
DASHBOARD
.
ROOT
);
}
catch
(
e
:
any
)
{
...
...
src/components/pages/dashboard/userDashboard/buyCoins/buyCoinSinlgeGame/CoinCalculator.tsx
View file @
a1188f74
...
...
@@ -40,10 +40,10 @@ export default function CoinCalculator({ slug }: { slug: string }) {
};
const
handleBuy
=
()
=>
{
if
(
Number
(
amount
)
<
2
0
)
{
if
(
Number
(
amount
)
<
2
)
{
return
dispatch
(
showToast
({
message
:
"Minimum amount is 2
0
"
,
message
:
"Minimum amount is 2"
,
variant
:
ToastVariant
.
ERROR
,
})
)
...
...
src/components/pages/dashboard/userDashboard/buyCoins/buyCoinSinlgeGame/checkout/index.tsx
View file @
a1188f74
...
...
@@ -14,16 +14,6 @@ import PaymentForm from './FortPay';
export
type
PaymentModeProps
=
"crypto"
|
"fortpay"
/**
* Before redirecting to an external payment gateway, we back up every auth-related
* key from localStorage into sessionStorage.
*
* Why sessionStorage?
* - It survives external redirects (the tab stays open, session is preserved).
* - It is scoped to the tab, so it won't leak to other tabs.
* - Unlike localStorage it won't be touched by any app boot logic that
* reinitialises the store and accidentally clears auth keys.
*/
const
AUTH_KEYS
=
[
'token'
,
'access_token'
,
'authToken'
,
'user'
,
'refresh_token'
];
const
BACKUP_PREFIX
=
'__payment_backup__'
;
...
...
@@ -173,8 +163,8 @@ export default function CheckoutPage({ amount, slug, bonus }: {
backupAuthToSession
();
window
.
location
.
href
=
response
?.
data
?.
payment_url
;
window
.
open
(
response
?.
data
?.
payment_url
,
"_blank"
);
//
window.location.href = response?.data?.payment_url;
}
catch
(
e
:
any
)
{
dispatch
(
...
...
src/routes/ReduxHydrator.tsx
View file @
a1188f74
"use client"
;
import
{
User
}
from
"@/types/auth"
;
export
default
function
ReduxHydrator
({
token
}:
{
token
:
string
;
})
{
console
.
log
(
token
);
export
default
function
ReduxHydrator
({
token
,
user
}:
{
token
:
string
;
user
:
User
})
{
console
.
log
({
token
,
user
});
// useEffect(() => {
// dispatch(setTokens({ access_token: token, user }));
...
...
src/routes/ServerPrivate.tsx
View file @
a1188f74
...
...
@@ -12,24 +12,16 @@ import ReduxHydrator from "./ReduxHydrator";
// }
export
default
async
function
ServerPrivate
({
children
}:
{
children
:
React
.
ReactNode
})
{
// ✅ Read cookie server-side
const
cookieStore
=
await
cookies
();
const
access_token
=
cookieStore
.
get
(
"access_token"
)?.
value
;
if
(
!
access_token
)
return
;
// const payload = decodeJwt(access_token);
// if (!payload || !payload.exp || payload.exp < Math.floor(Date.now() / 1000)) {
// redirect("/");
// }
// const user = payload;
const
user_cookie
=
cookieStore
.
get
(
"user"
)?.
value
;
const
user
=
user_cookie
?
JSON
.
parse
(
user_cookie
)
:
null
;
if
(
!
access_token
||!
user
)
return
;
return
(
<>
{
/* ✅ Hydrate Redux store on client */
}
<
ReduxHydrator
token=
{
access_token
}
/>
<
ReduxHydrator
token=
{
access_token
}
user=
{
user
}
/>
{
children
}
</>
);
...
...
src/slice/authSlice.ts
View file @
a1188f74
...
...
@@ -61,6 +61,7 @@ export const authSlice = createSlice({
localStorage
.
removeItem
(
"token"
);
}
Cookies
.
remove
(
"access_token"
);
Cookies
.
remove
(
"user"
);
},
}
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment