Skip to content

Commit

Permalink
Merge pull request polkassembly#655 from polkassembly/fix/kr/hot-fix
Browse files Browse the repository at this point in the history
fix: 🔥 hot fixes
  • Loading branch information
KanishkaRajputd authored Sep 15, 2023
2 parents c29dd88 + 391a343 commit 0371225
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 44 deletions.
66 changes: 34 additions & 32 deletions pages/api/v1/verification/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,39 +70,41 @@ const handler: NextApiHandler<IVerificationResponse | MessageType> = async (req,
return res.status(200).json({ message: VerificationStatus.VERFICATION_EMAIL_SENT });
}
}
if (checkingVerified === true) return res.status(200).json({ message: VerificationStatus.NOT_VERIFIED });

const message = {
from: FROM.email,
html: `Hello ${user.username},
<br>Click on the following link to complete email verification for your on chain identity: <a href="https://${network}.polkassembly.io/verify-email?token=${verificationToken}&identityVerification=${true}">Verify Email</a></br>
<br/>
<br>
Thank you,
</br>
<br>
Polkassembly Team
</br>`,
subject: 'Email Verification',
to: account
};
await sgMail
.send(message)
.then(() => {
res.status(200).json({ message: VerificationStatus.VERFICATION_EMAIL_SENT });
})
.catch((error: any) => {
return res.status(500).json({ message: error || 'Error sending email' });
if (checkingVerified === true) {
return res.status(200).json({ message: VerificationStatus.NOT_VERIFIED });
} else {
const message = {
from: FROM.email,
html: `Hello ${user.username},
<br>Click on the following link to complete email verification for your on chain identity: <a href="https://${network}.polkassembly.io/verify-email?token=${verificationToken}&identityVerification=${true}">Verify Email</a></br>
<br/>
<br>
Thank you,
</br>
<br>
Polkassembly Team
</br>`,
subject: 'Email Verification',
to: account
};
await sgMail
.send(message)
.then(() => {
res.status(200).json({ message: VerificationStatus.VERFICATION_EMAIL_SENT });
})
.catch((error: any) => {
return res.status(500).json({ message: error || 'Error sending email' });
});
await tokenVerificationRef.set({
created_at: new Date(),
email: account,
status: VerificationStatus.VERFICATION_EMAIL_SENT,
token: verificationToken,
user_id: userId,
verified: false
});
await tokenVerificationRef.set({
created_at: new Date(),
email: account,
status: VerificationStatus.VERFICATION_EMAIL_SENT,
token: verificationToken,
user_id: userId,
verified: false
});
return res.status(200).json({ message: VerificationStatus.VERFICATION_EMAIL_SENT });
return res.status(200).json({ message: VerificationStatus.VERFICATION_EMAIL_SENT });
}
} else if (type === 'twitter') {
const twitterVerificationDoc = await firestore.collection('twitter_verification_tokens').doc(String(userId)).get();

Expand Down
2 changes: 1 addition & 1 deletion src/components/AppLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ const getUserDropDown = (
{isGood && !isIdentityUnverified && (
<CheckCircleFilled
style={{ color: 'green' }}
className='rounded-[50%] border-none bg-white'
className='rounded-[50%] border-none bg-transparent'
/>
)}
<DownOutlined className='text-base text-navBlue hover:text-pink_primary' />
Expand Down
22 changes: 12 additions & 10 deletions src/components/OnchainIdentity/SocialVerification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import BN from 'bn.js';
import { useEffect, useState } from 'react';
import InprogressState from './InprogressState';
import VerifiedTick from '~assets/icons/verified-tick.svg';
import { useRouter } from 'next/router';

interface Props {
className?: string;
Expand Down Expand Up @@ -90,6 +91,7 @@ const SocialVerification = ({ className, socials, onCancel, setLoading, closeMod
const [status, setStatus] = useState({ email: '', twitter: '' });
const [fieldLoading, setFieldLoading] = useState<{ twitter: boolean; email: boolean }>({ email: false, twitter: false });
const [twitterVerificationStart, setTwitterVerificationStart] = useState<boolean>(false);
const router = useRouter();

const items: TimelineItemProps[] = [];

Expand Down Expand Up @@ -136,7 +138,7 @@ const SocialVerification = ({ className, socials, onCancel, setLoading, closeMod
key: 2
});
}
const handleLocalStorageSave = (field: any) => {
const handleLocalStorageSave = (field: any, socialsChanging?: boolean) => {
let data: any = localStorage.getItem('identityForm');
if (data) {
data = JSON.parse(data);
Expand All @@ -148,22 +150,21 @@ const SocialVerification = ({ className, socials, onCancel, setLoading, closeMod
...field
})
);
setSocials({
...socials,
email: { ...email, ...data?.email },
twitter: { ...twitter, ...data?.twitter }
});
socialsChanging &&
setSocials({
...socials,
email: { ...email, ...data?.email },
twitter: { ...twitter, ...data?.twitter }
});
};

const handleSetStates = (fieldName: ESocials, verified: boolean, verificationStatus: VerificationStatus, noStatusUpdate?: boolean) => {
if (ESocials.EMAIL === fieldName) {
setSocials({ ...socials, email: { ...email, verified } });
!noStatusUpdate && setStatus({ ...status, email: verificationStatus });
handleLocalStorageSave({ email: { ...email, verified } });
handleLocalStorageSave({ email: { ...email, verified } }, true);
} else {
setSocials({ ...socials, twitter: { ...twitter, verified } });
!noStatusUpdate && setStatus({ ...status, twitter: verificationStatus });
handleLocalStorageSave({ twitter: { ...twitter, verified } });
handleLocalStorageSave({ twitter: { ...twitter, verified } }, true);
}
};

Expand Down Expand Up @@ -254,6 +255,7 @@ const SocialVerification = ({ className, socials, onCancel, setLoading, closeMod
setLoading(false);
setOpenSuccessModal(true);
closeModal(true);
router.replace('/');
} else if (error) {
queueNotification({
header: 'Error!',
Expand Down
2 changes: 1 addition & 1 deletion src/ui-components/Address.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ const Address = ({
)}
<span
title={mainDisplay || encoded_addr}
className={`flex max-w-[85px] gap-x-1 font-semibold text-bodyBlue ${textClassName}`}
className={`flex ${truncateUsername && 'max-w-[85px] truncate'} gap-x-1 font-semibold text-bodyBlue ${textClassName}`}
>
{t1 && <span className={`${truncateUsername && 'truncate'}`}>{t1}</span>}
{sub && isSubVisible && <span className={`sub truncate ${textClassName}`}>{sub}</span>}
Expand Down

0 comments on commit 0371225

Please sign in to comment.