Commit b0a9a158 by Arjun Jhukal

minor change

parent 3294a2f4
...@@ -22,13 +22,11 @@ export default function PaymentSuccess() { ...@@ -22,13 +22,11 @@ export default function PaymentSuccess() {
useEffect(() => { useEffect(() => {
const hydrateAuthOnSuccess = async () => { const hydrateAuthOnSuccess = async () => {
try { try {
console.log('[PaymentSuccess] Starting auth hydration...');
// Try to restore auth from backup // Try to restore auth from backup
const result = restoreAuthFromCookies(); const result = restoreAuthFromCookies();
if (result.success && result.data) { if (result.success && result.data) {
console.log(`[PaymentSuccess] Auth restored from ${result.source}`);
// Update Redux store // Update Redux store
dispatch(setTokens({ dispatch(setTokens({
......
...@@ -23,7 +23,6 @@ export default function AuthHydrator() { ...@@ -23,7 +23,6 @@ export default function AuthHydrator() {
const result = restoreAuthFromCookies(); const result = restoreAuthFromCookies();
if (result.success && result.data) { if (result.success && result.data) {
console.log(`[AuthHydrator] Restored auth from ${result.source}`);
// Dispatch to Redux to update app state // Dispatch to Redux to update app state
dispatch(setTokens({ dispatch(setTokens({
......
...@@ -138,7 +138,6 @@ export default function PaymentModal({ ...@@ -138,7 +138,6 @@ export default function PaymentModal({
}); });
if (found) { if (found) {
console.log('[PaymentModal] Detected success redirect URL:', currentUrl);
setHasDetectedSuccess(true); setHasDetectedSuccess(true);
setIsLoading(false); setIsLoading(false);
onSuccess?.(); onSuccess?.();
......
...@@ -15,9 +15,7 @@ export default function UpdatePassword() { ...@@ -15,9 +15,7 @@ export default function UpdatePassword() {
const { open, provider } = useSelector((state: RootState) => state?.updatePasswordSlice); const { open, provider } = useSelector((state: RootState) => state?.updatePasswordSlice);
const [updateNewPassword, { isLoading }] = useUpdateUserGamePasswordMutation(); const [updateNewPassword, { isLoading }] = useUpdateUserGamePasswordMutation();
console.log({
open, provider
})
const formik = useFormik({ const formik = useFormik({
initialValues: { password: "" }, initialValues: { password: "" },
validationSchema: Yup.object({ validationSchema: Yup.object({
...@@ -28,7 +26,6 @@ export default function UpdatePassword() { ...@@ -28,7 +26,6 @@ export default function UpdatePassword() {
onSubmit: async (values) => { onSubmit: async (values) => {
try { try {
console.log("New password:", values.password);
const response = await updateNewPassword({ const response = await updateNewPassword({
password: values.password, password: values.password,
provider: provider || "" provider: provider || ""
......
...@@ -77,7 +77,6 @@ export default function LoginPage() { ...@@ -77,7 +77,6 @@ export default function LoginPage() {
secure: process.env.NODE_ENV === 'production', secure: process.env.NODE_ENV === 'production',
sameSite: 'Strict', sameSite: 'Strict',
}); });
console.log("Login Response:", response?.data?.user?.role.toLowerCase() === "user");
router.replace(response?.data?.user?.role?.toLowerCase() === "user" ? "/credentials" : "/"); router.replace(response?.data?.user?.role?.toLowerCase() === "user" ? "/credentials" : "/");
} }
catch (e: any) { catch (e: any) {
......
...@@ -168,7 +168,6 @@ export default function RegisterPage() { ...@@ -168,7 +168,6 @@ export default function RegisterPage() {
autoTime: true, autoTime: true,
}), }),
); );
console.log("Register response:", response?.data?.redirection_url);
if (response?.data?.redirection_url) { if (response?.data?.redirection_url) {
window.open(response?.data?.redirection_url, "_blank"); window.open(response?.data?.redirection_url, "_blank");
setAcuityUrl(response.data.redirection_url); setAcuityUrl(response.data.redirection_url);
......
...@@ -27,7 +27,7 @@ export const PlayerValidationSchema = (isEdit: boolean) => Yup.object().shape({ ...@@ -27,7 +27,7 @@ export const PlayerValidationSchema = (isEdit: boolean) => Yup.object().shape({
.matches(/^\+?\d{7,15}$/, "Invalid phone number") .matches(/^\+?\d{7,15}$/, "Invalid phone number")
.required("Phone is required"), .required("Phone is required"),
password: isEdit password: isEdit
? Yup.string().nullable() // not required in edit mode ? Yup.string().nullable()
: Yup.string().min(6, "Password must be at least 6 characters").required("Password is required"), : Yup.string().min(6, "Password must be at least 6 characters").required("Password is required"),
password_confirmation: isEdit ? Yup.string().nullable() : Yup.string().when("password", { password_confirmation: isEdit ? Yup.string().nullable() : Yup.string().when("password", {
is: (val: string) => !!val, is: (val: string) => !!val,
......
...@@ -97,7 +97,6 @@ export default function PaymentForm({ id, amount, type }: DepositProps & { type: ...@@ -97,7 +97,6 @@ export default function PaymentForm({ id, amount, type }: DepositProps & { type:
}, },
callback: async (response: any) => { callback: async (response: any) => {
try { try {
console.log("token value is", response);
await payViaFortPay({ await payViaFortPay({
id, id,
amount, amount,
...@@ -111,7 +110,6 @@ export default function PaymentForm({ id, amount, type }: DepositProps & { type: ...@@ -111,7 +110,6 @@ export default function PaymentForm({ id, amount, type }: DepositProps & { type:
// Backup auth before redirecting to success page // Backup auth before redirecting to success page
backupAuthToCookies(); backupAuthToCookies();
console.log('[FortPay] Auth backed up before redirect');
router.push(`/buy-coins/${id}/success`); router.push(`/buy-coins/${id}/success`);
} catch (e: any) { } catch (e: any) {
......
...@@ -19,7 +19,6 @@ export default function BuyCoinGameListPage({ ...@@ -19,7 +19,6 @@ export default function BuyCoinGameListPage({
const gameInfo = coins?.data?.game_information || {} const gameInfo = coins?.data?.game_information || {}
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
console.log("coins", coins);
return ( return (
<section className="buy__coin__root"> <section className="buy__coin__root">
<div className="section__title mb-4 lg:mb-8 max-w-[520px]"> <div className="section__title mb-4 lg:mb-8 max-w-[520px]">
...@@ -33,7 +32,6 @@ export default function BuyCoinGameListPage({ ...@@ -33,7 +32,6 @@ export default function BuyCoinGameListPage({
{games.data?.data.map((game) => { {games.data?.data.map((game) => {
const info = gameInfo[game.provider.toLowerCase()] || { balance: 0, type: 'sc' } const info = gameInfo[game.provider.toLowerCase()] || { balance: 0, type: 'sc' }
const CoinIcon = info.type === 'gc' ? GoldCoinIcon : SilverCoinIcon const CoinIcon = info.type === 'gc' ? GoldCoinIcon : SilverCoinIcon
console.log(info.has_changed_password)
return ( return (
<div key={game.id} className={`col-span-1 ${info.type === 'gc' ? "hidden" : ""}`}> <div key={game.id} className={`col-span-1 ${info.type === 'gc' ? "hidden" : ""}`}>
......
...@@ -43,7 +43,6 @@ export default function CredentialsCard({ cred }: { cred: CredentialsProps }) { ...@@ -43,7 +43,6 @@ export default function CredentialsCard({ cred }: { cred: CredentialsProps }) {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const newBalance = useAppSelector((state) => state.userBalanceSlice); const newBalance = useAppSelector((state) => state.userBalanceSlice);
console.log("newBalance in cred card:", newBalance);
const providerBalance: any = newBalance.providerAndBalance const providerBalance: any = newBalance.providerAndBalance
?.find((item: any) => item?.provider === cred.name); ?.find((item: any) => item?.provider === cred.name);
return ( return (
...@@ -85,13 +84,11 @@ export default function CredentialsCard({ cred }: { cred: CredentialsProps }) { ...@@ -85,13 +84,11 @@ export default function CredentialsCard({ cred }: { cred: CredentialsProps }) {
icon={true} icon={true}
onClick={() => { onClick={() => {
if (balance?.has_changed_password) { if (balance?.has_changed_password) {
console.log("password changes");
dispatch(openPasswordDialog({ dispatch(openPasswordDialog({
provider: cred?.name, provider: cred?.name,
})); }));
} }
else { else {
console.log("password not changes");
refetch(); refetch();
} }
}} }}
...@@ -139,7 +136,6 @@ export default function CredentialsCard({ cred }: { cred: CredentialsProps }) { ...@@ -139,7 +136,6 @@ export default function CredentialsCard({ cred }: { cred: CredentialsProps }) {
onClick={(e) => { onClick={(e) => {
if (balance?.has_changed_password) { if (balance?.has_changed_password) {
e.preventDefault(); e.preventDefault();
console.log("password changes");
dispatch(openPasswordDialog({ dispatch(openPasswordDialog({
provider: cred?.name, provider: cred?.name,
})); }));
......
...@@ -38,7 +38,6 @@ export default function ResetPasswordDialog({ ...@@ -38,7 +38,6 @@ export default function ResetPasswordDialog({
onClose: () => void; onClose: () => void;
name: string; name: string;
}) { }) {
console.log("ResetPasswordDialog name:", name);
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const [resetGamePassord, { isLoading }] = useChangeUserGamePasswordMutation(); const [resetGamePassord, { isLoading }] = useChangeUserGamePasswordMutation();
......
...@@ -131,7 +131,6 @@ export default function WithdrawlPage({ ...@@ -131,7 +131,6 @@ export default function WithdrawlPage({
}) })
); );
} catch (e: any) { } catch (e: any) {
console.log("Withdrawal Error:", e);
dispatch( dispatch(
showToast({ showToast({
message: e?.data?.message || "Something went wrong", message: e?.data?.message || "Something went wrong",
...@@ -179,7 +178,6 @@ export default function WithdrawlPage({ ...@@ -179,7 +178,6 @@ export default function WithdrawlPage({
} }
}; };
console.log("Formik Errors:", formik.values.withdrawl_amounts);
return ( return (
<section className="withdrawl__root"> <section className="withdrawl__root">
<div className="section__title mb-4 lg:mb-8 max-w-[560px]"> <div className="section__title mb-4 lg:mb-8 max-w-[560px]">
......
...@@ -21,7 +21,6 @@ export default function ProtectedLink({ href, className, children, target, rel, ...@@ -21,7 +21,6 @@ export default function ProtectedLink({ href, className, children, target, rel,
const { data } = useGetGamesPasswordStatusQuery({ provider: provider || "" }, { skip: !provider }); const { data } = useGetGamesPasswordStatusQuery({ provider: provider || "" }, { skip: !provider });
console.log("user data", { data, provider });
const handleClick = (e: React.MouseEvent) => { const handleClick = (e: React.MouseEvent) => {
if (!user) { if (!user) {
......
...@@ -3,28 +3,43 @@ import { RootState } from "@/hooks/store"; ...@@ -3,28 +3,43 @@ import { RootState } from "@/hooks/store";
import { fetchBaseQuery } from "@reduxjs/toolkit/query/react"; import { fetchBaseQuery } from "@reduxjs/toolkit/query/react";
let globalDeviceId: string | undefined = undefined; let globalDeviceId: string | undefined = undefined;
let globalDeviceFingerprint: string | undefined = undefined;
let resolveFingerprint: (() => void) | undefined;
const fingerprintReady = new Promise<void>((resolve) => {
resolveFingerprint = resolve;
});
// Safety timeout — never block forever
const fingerprintTimeout = setTimeout(() => resolveFingerprint?.(), 4000);
export const setGlobalDeviceId = (id?: string) => { export const setGlobalDeviceId = (id?: string) => {
globalDeviceId = id; globalDeviceId = id;
}; };
export const baseQuery = fetchBaseQuery({
baseUrl:
(process.env.NEXT_PUBLIC_FRONTEND_URL || "") + "/api/backend",
export const setGlobalDeviceFingerprint = (fingerprint?: string) => {
globalDeviceFingerprint = fingerprint;
clearTimeout(fingerprintTimeout);
resolveFingerprint?.();
};
const base = fetchBaseQuery({
baseUrl: (process.env.NEXT_PUBLIC_FRONTEND_URL || "") + "/api/backend",
credentials: "include", credentials: "include",
prepareHeaders: (headers, { getState }) => { prepareHeaders: (headers, { getState }) => {
const token = (getState() as RootState).auth.access_token; const token = (getState() as RootState).auth.access_token;
headers.set("Accept", "application/json"); headers.set("Accept", "application/json");
if (globalDeviceId) { if (globalDeviceId) headers.set("X-Device-Id", globalDeviceId);
headers.set("X-Device-Id", globalDeviceId); if (globalDeviceFingerprint) headers.set("X-Device-Fingerprint", globalDeviceFingerprint);
} if (token) headers.set("Authorization", `Bearer ${token}`);
if (token) {
headers.set("Authorization", `Bearer ${token}`);
}
return headers; return headers;
}, },
}); });
export const baseQuery: ReturnType<typeof fetchBaseQuery> = async (queryArg, api, extraOptions) => {
await fingerprintReady;
return base(queryArg, api, extraOptions);
};
\ No newline at end of file
...@@ -11,7 +11,7 @@ import Palette from './palette'; ...@@ -11,7 +11,7 @@ import Palette from './palette';
export default function ThemeCustomization({ children }: { children: React.ReactNode }) { export default function ThemeCustomization({ children }: { children: React.ReactNode }) {
const [theme, setTheme] = React.useState(ThemeMode.DARK); const [_theme, setTheme] = React.useState(ThemeMode.DARK);
const user = useAppSelector((state) => state.auth.user); const user = useAppSelector((state) => state.auth.user);
const globalStyles = { const globalStyles = {
...@@ -33,7 +33,6 @@ export default function ThemeCustomization({ children }: { children: React.React ...@@ -33,7 +33,6 @@ export default function ThemeCustomization({ children }: { children: React.React
}, [user]); }, [user]);
console.log(theme)
return ( return (
<StyledEngineProvider injectFirst> <StyledEngineProvider injectFirst>
<NextAppDirEmotionCacheProvider options={{ key: 'mui' }}> <NextAppDirEmotionCacheProvider options={{ key: 'mui' }}>
......
...@@ -64,7 +64,6 @@ export function backupAuthToCookies(): void { ...@@ -64,7 +64,6 @@ export function backupAuthToCookies(): void {
}); });
sessionStorage.setItem(TIMESTAMP_KEY, timestamp.toString()); sessionStorage.setItem(TIMESTAMP_KEY, timestamp.toString());
console.log('[Auth] Backed up auth data to cookies and sessionStorage');
} catch (error) { } catch (error) {
console.error('[Auth] Failed to backup auth data:', error); console.error('[Auth] Failed to backup auth data:', error);
} }
...@@ -88,7 +87,6 @@ export function restoreAuthFromCookies(): AuthRestorationResult { ...@@ -88,7 +87,6 @@ export function restoreAuthFromCookies(): AuthRestorationResult {
const sessionUser = sessionStorage.getItem(`${SESSION_BACKUP_PREFIX}user`); const sessionUser = sessionStorage.getItem(`${SESSION_BACKUP_PREFIX}user`);
if (sessionAccessToken && sessionUser) { if (sessionAccessToken && sessionUser) {
console.log('[Auth] Restoring from sessionStorage');
const userData = JSON.parse(sessionUser); const userData = JSON.parse(sessionUser);
const authData: AuthData = { const authData: AuthData = {
access_token: sessionAccessToken, access_token: sessionAccessToken,
...@@ -108,7 +106,6 @@ export function restoreAuthFromCookies(): AuthRestorationResult { ...@@ -108,7 +106,6 @@ export function restoreAuthFromCookies(): AuthRestorationResult {
// Try cookies (cross-tab scenario from payment provider) // Try cookies (cross-tab scenario from payment provider)
const wasRedirected = Cookies.get(`${BACKUP_PREFIX}redirected`); const wasRedirected = Cookies.get(`${BACKUP_PREFIX}redirected`);
if (!wasRedirected) { if (!wasRedirected) {
console.log('[Auth] No redirect marker found');
return { success: false, source: 'none', data: null }; return { success: false, source: 'none', data: null };
} }
...@@ -117,7 +114,6 @@ export function restoreAuthFromCookies(): AuthRestorationResult { ...@@ -117,7 +114,6 @@ export function restoreAuthFromCookies(): AuthRestorationResult {
const cookieUser = Cookies.get(`${BACKUP_PREFIX}user`); const cookieUser = Cookies.get(`${BACKUP_PREFIX}user`);
if (cookieAccessToken && cookieUser) { if (cookieAccessToken && cookieUser) {
console.log('[Auth] Restoring from cookies');
const userData = JSON.parse(cookieUser); const userData = JSON.parse(cookieUser);
const authData: AuthData = { const authData: AuthData = {
access_token: cookieAccessToken, access_token: cookieAccessToken,
...@@ -138,7 +134,6 @@ export function restoreAuthFromCookies(): AuthRestorationResult { ...@@ -138,7 +134,6 @@ export function restoreAuthFromCookies(): AuthRestorationResult {
return { success: true, source: 'cookies', data: authData }; return { success: true, source: 'cookies', data: authData };
} }
console.log('[Auth] No valid backup found in cookies or sessionStorage');
return { success: false, source: 'none', data: null }; return { success: false, source: 'none', data: null };
} catch (error) { } catch (error) {
console.error('[Auth] Failed to restore auth data:', error); console.error('[Auth] Failed to restore auth data:', error);
...@@ -156,7 +151,6 @@ function cleanupAuthCookies(): void { ...@@ -156,7 +151,6 @@ function cleanupAuthCookies(): void {
Cookies.remove(`${BACKUP_PREFIX}${key}`); Cookies.remove(`${BACKUP_PREFIX}${key}`);
}); });
Cookies.remove(`${BACKUP_PREFIX}redirected`); Cookies.remove(`${BACKUP_PREFIX}redirected`);
console.log('[Auth] Cleaned up backup cookies');
} }
/** /**
...@@ -169,7 +163,6 @@ function cleanupAuthSessionStorage(): void { ...@@ -169,7 +163,6 @@ function cleanupAuthSessionStorage(): void {
sessionStorage.removeItem(`${SESSION_BACKUP_PREFIX}${key}`); sessionStorage.removeItem(`${SESSION_BACKUP_PREFIX}${key}`);
}); });
sessionStorage.removeItem(TIMESTAMP_KEY); sessionStorage.removeItem(TIMESTAMP_KEY);
console.log('[Auth] Cleaned up sessionStorage backup');
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment