diff --git a/src/App.svelte b/src/App.svelte index 9c477de..816e543 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -15,6 +15,7 @@ import bg from '$lib/assets/sparrowLogoBackground.svg'; import ExternalNavigation from './routing/ExternalNavigation.svelte'; import constants from '$lib/utils/constants'; + import VerifyEmail from './pages/Auth/verify-email/VerifyEmail.svelte'; export let url = '/'; @@ -27,6 +28,7 @@ + diff --git a/src/lib/services/auth.service.ts b/src/lib/services/auth.service.ts index cad9bce..158b9ba 100644 --- a/src/lib/services/auth.service.ts +++ b/src/lib/services/auth.service.ts @@ -58,4 +58,18 @@ const resetPassword = async (changePasswordBody: resetPasswordPostBody) => { return response; }; -export { registerUser, loginUser, forgotPassword, loginWithGoogle, verifyEmail, resetPassword, getUser }; +const sendUserEmailVerification = async (emailInfo: EmailPostBody) => { + const response = await makeRequest('POST', `${apiUrl}/api/user/send-user-verification-email`, { + body: emailInfo + }); + return response; +}; + +const verifyUserEmail = async (verifyInfo: verifyPostbody) => { + const response = await makeRequest('POST', `${apiUrl}/api/user/verify-user-email`, { + body: verifyInfo + }); + return response; +}; + +export { registerUser, loginUser, forgotPassword, loginWithGoogle, verifyEmail, resetPassword, getUser, sendUserEmailVerification, verifyUserEmail }; diff --git a/src/pages/Auth/entry-point/EntryPoint.svelte b/src/pages/Auth/entry-point/EntryPoint.svelte index 6369a98..25528ad 100644 --- a/src/pages/Auth/entry-point/EntryPoint.svelte +++ b/src/pages/Auth/entry-point/EntryPoint.svelte @@ -45,103 +45,111 @@ loadingMessage={redirectRules.loadingMessage} /> {:else} - -
- -
-

- Welcome to Sparrow! -

- +
+
+ + + +
{/if} diff --git a/src/pages/Auth/verify-email/verify-email.ts b/src/pages/Auth/verify-email/verify-email.ts new file mode 100644 index 0000000..315174b --- /dev/null +++ b/src/pages/Auth/verify-email/verify-email.ts @@ -0,0 +1,23 @@ +import { verifyUserEmail } from '$lib/services/auth.service'; +import { errorMessageText } from '$lib/store/auth.store'; +import type { verifyPostbody } from '$lib/utils/dto'; +export const isSuccessfulResponse = writable(false); + +import { writable } from 'svelte/store'; + +export const handleVerifyEmail = async (verifyCodeCredential: verifyPostbody) => { + const response = await verifyUserEmail(verifyCodeCredential); + if (response.isSuccessful) { + errorMessageText.set(""); + } else { + isSuccessfulResponse.set(true); + if (response.message === 'verificationCode should not be empty') { + errorMessageText.set('Please enter the 6-digit verification code.'); + } + + if (response.message === 'Wrong Code') { + errorMessageText.set('You have entered wrong code, Please check again.'); + } + } + return response; +};