Overwrite subscriber ID in thanks page

This commit is contained in:
Shreerang Kale 2024-08-09 11:03:25 +05:30
parent cf6729603e
commit 0f262dea5a
7 changed files with 20 additions and 21 deletions

View File

@ -1,5 +1,7 @@
export const WALLET_DISCLAIMER_MSG = 'You are connecting to an experimental wallet! It is not secure. Do not use it elsewhere and/or for managing real assets.'
export const WALLET_DISCLAIMER_MSG = 'You are connecting to an experimental wallet! It is not secure. Do not use it elsewhere and/or for managing real assets.';
export const REDIRECT_EMAIL_MSG = 'Close this tab and the confirmation link in your email will bring you back to the onboarding app.'
export const REDIRECT_EMAIL_MSG = 'Close this tab and the confirmation link in your email will bring you back to the onboarding app.';
export const ENABLE_KYC = false;
export const SUBSCRIBER_ID_HASH_KEY = 'subscriberIdHash';

View File

@ -15,7 +15,9 @@ const ConnectWallet = () => {
useEffect(() => {
if (session) {
navigate("/sign-with-nitro-key");
navigate("/sign-with-nitro-key", {
state: location.state
});
}
}, [session, navigate, location]);

View File

@ -8,7 +8,7 @@ import SumsubWebSdk from "@sumsub/websdk-react";
import { MessageHandler } from "@sumsub/websdk";
import { config, fetchAccessToken, getAccessTokenExpirationHandler, options } from "../utils/sumsub";
import { ENABLE_KYC } from "../constants";
import { ENABLE_KYC, SUBSCRIBER_ID_HASH_KEY } from "../constants";
interface Participant {
cosmosAddress: string;
@ -48,7 +48,7 @@ const OnboardingSuccess = () => {
return;
}
localStorage.removeItem('subscriberIdHash');
localStorage.removeItem(SUBSCRIBER_ID_HASH_KEY);
setParticipant(participant);
} catch (error) {

View File

@ -12,6 +12,7 @@ import { StargateClient } from "@cosmjs/stargate";
import { useWalletConnectContext } from "../context/WalletConnectContext";
import SelectRoleCard, {Role} from "../components/SelectRoleCard";
import { SUBSCRIBER_ID_HASH_KEY } from "../constants";
const SignWithCosmos = () => {
const { session, signClient } = useWalletConnectContext();
@ -35,7 +36,7 @@ const SignWithCosmos = () => {
};
const ethAddress = innerMessage!.address;
const subscriberIdHash = localStorage.getItem('subscriberIdHash');
const subscriberIdHash = localStorage.getItem(SUBSCRIBER_ID_HASH_KEY);
const createCosmosClient = useCallback(async (endpoint: string) => {
return await StargateClient.connect(endpoint);

View File

@ -13,7 +13,7 @@ import LoadingButton from '@mui/lab/LoadingButton';
import { utf8ToHex } from "@walletconnect/encoding";
import { useWalletConnectContext } from "../context/WalletConnectContext";
import { ENABLE_KYC } from "../constants";
import { ENABLE_KYC, SUBSCRIBER_ID_HASH_KEY } from "../constants";
const SignWithNitroKey = () => {
@ -34,14 +34,12 @@ const SignWithNitroKey = () => {
const [isLoading, setIsLoading] = useState(false);
const subscriberIdHash = localStorage.getItem('subscriberIdHash');
const subscriberIdHash = localStorage.getItem(SUBSCRIBER_ID_HASH_KEY);
useEffect(()=>{
if(!subscriberIdHash){
setIsLoading(false)
enqueueSnackbar("Subscriber ID not found. Please verify your email and try again", { variant: "error" });
}
}, [subscriberIdHash])
const message = useMemo(() => {
return {

View File

@ -4,6 +4,7 @@ import { jwtDecode } from "jwt-decode";
import { ethers } from 'ethers';
import { Box, colors, Typography } from '@mui/material';
import { SUBSCRIBER_ID_HASH_KEY } from '../constants';
interface JwtPayload {
subscriber_id: string;
@ -19,11 +20,6 @@ const Thanks: React.FC = () => {
const [err, setErr] = useState<string>();
useEffect(() => {
const localSubscriberIdHash = localStorage.getItem('localSubscriberIdHash');
if(localSubscriberIdHash){
navigate('/connect-wallet');
}
const queryParams = new URLSearchParams(location.search);
const token = queryParams.get('jwt_token');
@ -46,7 +42,7 @@ const Thanks: React.FC = () => {
const subscriberIdBytes = ethers.utils.toUtf8Bytes(decoded.subscriber_id);
const subscriberIdHash = ethers.utils.sha256(subscriberIdBytes);
localStorage.setItem('subscriberIdHash', subscriberIdHash);
localStorage.setItem(SUBSCRIBER_ID_HASH_KEY, subscriberIdHash);
navigate('/connect-wallet');
} catch (error) {

View File

@ -45,13 +45,13 @@ const UserVerification = () => {
useEffect(() => {
if (applicationSubmitted && kycId !== '') {
const kycIdHash = ethers.utils.sha256(ethers.utils.toUtf8Bytes(kycId));
localStorage.setItem('subscriberIdHash', kycIdHash);
navigate("/sign-with-cosmos", {
state: {
message,
cosmosAddress,
receivedEthSig,
kycIdHash
}})
}
}, [applicationSubmitted, kycId, navigate, cosmosAddress, message, receivedEthSig]);