diff --git a/src/routes/dashboard/settings/+page.server.ts b/src/routes/dashboard/settings/+page.server.ts index 4b13cc88..792e7ad8 100644 --- a/src/routes/dashboard/settings/+page.server.ts +++ b/src/routes/dashboard/settings/+page.server.ts @@ -1,3 +1,4 @@ +import { SECRET_NOREPLY_EMAIL_PASSWORD } from '$env/static/private'; import { change_animation } from '$lib/server/user/account/change_animation'; import { change_email } from '$lib/server/user/account/change_email'; import { change_handicap } from '$lib/server/user/account/change_handicap'; @@ -11,6 +12,7 @@ import { User_Model } from '$lib/server/user/models'; import { cookie_options } from '$lib/server/user/utils'; import { fail, redirect, type Actions } from '@sveltejs/kit'; import type { Types } from 'mongoose'; +import nodemailer from 'nodemailer'; import type { PageServerLoad } from '../$types'; interface HandicapHistory { @@ -211,5 +213,53 @@ export const actions: Actions = { const message = `Your animation settings got changed`; return { message, animation }; + }, + verify: async (event) => { + const data = await event.request.formData(); + const email = (data.get('email') as string)?.toLowerCase()?.trim(); + + const user = await User_Model?.findOne({ 'user.email': email }); + + const verification_code = user?.user?.verification_code as string; + const name = user?.user?.name; + + const transporter = nodemailer.createTransport({ + host: 'mail.privateemail.com', + port: 465, + secure: true, + auth: { + user: 'noreply@realgolf.games', + pass: `${SECRET_NOREPLY_EMAIL_PASSWORD}` + } + }); + + async function sendEmail() { + try { + // send mail with defined transport object + const info = await transporter.sendMail({ + from: 'RealGolf.Games ', + to: `'${name}' <${email}>`, + subject: 'Verification Code for RealGolf.Games Account', + html: ` + Your verification code is: ${verification_code}
+ + Please enter this code in the verification form to complete your registration.
+ Click here to verify your account + ` + }); + + console.log('Message sent: %s', info.messageId); + + const message = 'Email sent succesfully'; + + return { message }; + } catch (error) { + console.error('Error sending email:', error); + + return { error }; + } + } + + await sendEmail(); } }; diff --git a/src/routes/dashboard/settings/+page.svelte b/src/routes/dashboard/settings/+page.svelte index eb4e3cf8..7ad02412 100644 --- a/src/routes/dashboard/settings/+page.svelte +++ b/src/routes/dashboard/settings/+page.svelte @@ -90,7 +90,7 @@

{$_('your_id')}: {data.id}

- +

{$_('your_id_info')}

@@ -139,6 +139,18 @@
+ +
+
+ +
+ + +
+
+ + +
@@ -153,12 +165,12 @@ })}

- {$_("when_handicap_changed")} + {$_('when_handicap_changed')}

- +
@@ -167,15 +179,15 @@ {#if handicap_history && handicap_history.length > 0}
- {$_("handicap_hstory")} + {$_('handicap_hstory')} {#each handicap_history.slice().reverse() as handicap}
-

{$_("handicap")}: {handicap.handicap}

-

{$_("updated_at_the")}: {new Date(handicap.date).toLocaleString()}

+

{$_('handicap')}: {handicap.handicap}

+

{$_('updated_at_the')}: {new Date(handicap.date).toLocaleString()}

{/each}
- +
@@ -183,12 +195,12 @@
-

{$_("measurement_unit")}

+

{$_('measurement_unit')}

- {$_("current_measurement_unit")}: {capitalizeFirstLetter(data.measurement_unit)} + {$_('current_measurement_unit')}: {capitalizeFirstLetter(data.measurement_unit)}

- + - - - + + +
-

{$_("rounded_corners")}

+

{$_('rounded_corners')}

- {$_("current_rounded_corner")}: {JSON.stringify(data.rounded_corners)} + {$_('current_rounded_corner')}: {JSON.stringify(data.rounded_corners)}

- + {$_('update')} -

{$_("animations")}

+

{$_('animations')}

- {$_("current_animation_setting")}: {JSON.stringify(data.animation)} + {$_('current_animation_setting')}: {JSON.stringify(data.animation)}

- +

@@ -247,11 +259,11 @@
- +
{/if} diff --git a/src/routes/support/+page.server.ts b/src/routes/support/+page.server.ts index fa88a109..921571a9 100644 --- a/src/routes/support/+page.server.ts +++ b/src/routes/support/+page.server.ts @@ -53,7 +53,6 @@ export const actions: Actions = { }); console.log('Message sent: %s', info.messageId); - console.log('Preview URL: %s', nodemailer.getTestMessageUrl(info)); } catch (error) { console.error('Error sending email:', error); }