-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add email verification reminder page for verification of email (#379)
* feat: add stub email verification reminder page
- Loading branch information
1 parent
2136356
commit f0269e6
Showing
14 changed files
with
191 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,7 @@ | |
margin: 0.5rem 0; | ||
width: 100%; | ||
} | ||
|
||
.auth.verify-email-reminder { | ||
max-width: var(--user-auth-max-width, 30rem); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
const SUPERTOKENS_API_BASE_PATH_DEFAULT = "/auth"; | ||
|
||
export { SUPERTOKENS_API_BASE_PATH_DEFAULT }; | ||
enum EMAIL_VERIFICATION { | ||
EMAIL_ALREADY_VERIFIED = "EMAIL_ALREADY_VERIFIED", | ||
ERROR = "ERROR", | ||
OK = "OK", | ||
EMAIL_ALREADY_VERIFIED_ERROR = "EMAIL_ALREADY_VERIFIED_ERROR", | ||
EMAIL_VERIFICATION_INVALID_TOKEN_ERROR = "EMAIL_VERIFICATION_INVALID_TOKEN_ERROR", | ||
} | ||
|
||
export { EMAIL_VERIFICATION, SUPERTOKENS_API_BASE_PATH_DEFAULT }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
packages/vue-user/src/supertokens/resend-email-verification.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { sendVerificationEmail } from "supertokens-web-js/recipe/emailverification"; | ||
|
||
type resendEmailStatus = "OK" | "EMAIL_ALREADY_VERIFIED_ERROR"; | ||
|
||
const resendVerificationEmail = async (): Promise< | ||
resendEmailStatus | undefined | ||
> => { | ||
const response = await sendVerificationEmail(); | ||
|
||
return response.status; | ||
}; | ||
|
||
export default resendVerificationEmail; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import EmailVerification from "supertokens-web-js/recipe/emailverification"; | ||
|
||
const verifyEmail = async () => { | ||
const { isVerified } = await EmailVerification.isEmailVerified(); | ||
|
||
if (isVerified) { | ||
return { status: "EMAIL_ALREADY_VERIFIED" }; | ||
} else { | ||
const response = await EmailVerification.verifyEmail(); | ||
|
||
return { status: response.status }; | ||
} | ||
}; | ||
|
||
export default verifyEmail; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<template> | ||
<Page | ||
:title="t('user.emailVerification.title')" | ||
class="auth verify-email-reminder" | ||
> | ||
<Card> | ||
<p>{{ t("user.emailVerification.messages.verifyEmail") }}</p> | ||
|
||
<template #footer> | ||
<ButtonElement | ||
:label="t('user.emailVerification.button.label')" | ||
@click="handleResend" | ||
/> | ||
</template> | ||
</Card> | ||
</Page> | ||
</template> | ||
|
||
<script lang="ts"> | ||
export default { | ||
name: "VerifyEmail", | ||
}; | ||
</script> | ||
|
||
<script setup lang="ts"> | ||
import { useI18n } from "@dzangolab/vue3-i18n"; | ||
import { ButtonElement, Card } from "@dzangolab/vue3-ui"; | ||
import { EMAIL_VERIFICATION } from "../constant"; | ||
import { useTranslations, emitter } from "../index"; | ||
import { resendVerificationEmail } from "../supertokens"; | ||
const messages = useTranslations(); | ||
const { t } = useI18n({ messages }); | ||
const handleResend = () => { | ||
resendVerificationEmail() | ||
.then((status) => { | ||
if (status === EMAIL_VERIFICATION.OK) { | ||
emitter.emit("notify", { | ||
text: t("user.emailVerification.messages.resend.success"), | ||
type: "success", | ||
}); | ||
} else if (status === EMAIL_VERIFICATION.EMAIL_ALREADY_VERIFIED_ERROR) { | ||
emitter.emit("notify", { | ||
text: t("user.emailVerification.messages.resend.alreadyVerified"), | ||
type: "info", | ||
}); | ||
} | ||
}) | ||
.catch(() => { | ||
emitter.emit("notify", { | ||
text: t("user.emailVerification.messages.resend.error"), | ||
type: "error", | ||
}); | ||
}); | ||
}; | ||
</script> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.