add 'already activated' response

This commit is contained in:
Elliot DeNolf
2020-09-24 10:54:00 -04:00
parent 0c3986917f
commit 96ccebdedd
2 changed files with 8 additions and 3 deletions

View File

@@ -10,15 +10,14 @@ async function verifyEmail(args) {
// 2. Perform password reset
// /////////////////////////////////////
// TODO: How do we know which collection this is?
const user = await args.collection.Model.findOne({
_verificationToken: args.token,
});
if (!user) throw new APIError('User not found.', httpStatus.BAD_REQUEST);
if (user && user._verified === true) throw new APIError('Already activated', httpStatus.ACCEPTED);
user._verified = true;
user._verificationToken = null;
await user.save();
}

View File

@@ -34,6 +34,12 @@ const Verify = () => {
return <Login />;
}
const getText = () => {
if (verifyResult?.status === 200) return 'Verified Successfully';
if (verifyResult?.status === 202) return 'Already Activated';
return 'Unable To Verify';
};
return (
<MinimalTemplate className={baseClass}>
<Meta
@@ -45,7 +51,7 @@ const Verify = () => {
<Logo />
</div>
<h2>
{verifyResult?.status === 200 ? 'Verified Successfully' : 'Unable To Verify'}
{getText()}
</h2>
{isAdminUser && verifyResult?.status === 200 && (
<Button