mirror of
https://github.com/PretendoNetwork/account.git
synced 2026-09-13 22:05:20 -05:00
Merge pull request #99 from ItzSwirlz/dev
Some checks failed
Build and Publish Docker Image / build-publish (push) Has been cancelled
Some checks failed
Build and Publish Docker Image / build-publish (push) Has been cancelled
Implement email confirmation for parental controls (send_confirmation/pin/:email)
This commit is contained in:
@@ -2,8 +2,8 @@ import dns from 'node:dns';
|
||||
import express from 'express';
|
||||
import xmlbuilder from 'xmlbuilder';
|
||||
import moment from 'moment';
|
||||
import { getPNIDByPID } from '@/database';
|
||||
import { sendEmailConfirmedEmail, sendConfirmationEmail, sendForgotPasswordEmail } from '@/util';
|
||||
import { getPNIDByEmailAddress, getPNIDByPID } from '@/database';
|
||||
import { sendEmailConfirmedEmail, sendConfirmationEmail, sendForgotPasswordEmail, sendEmailConfirmedParentalControlsEmail } from '@/util';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@@ -125,6 +125,35 @@ router.get('/resend_confirmation', async (request: express.Request, response: ex
|
||||
response.status(200).send('');
|
||||
});
|
||||
|
||||
/**
|
||||
* [GET]
|
||||
* Replacement for: https://account.nintendo.net/v1/api/support/send_confirmation/pin/:email
|
||||
* Description: Sends a users confirmation email that their email has been registered for parental controls
|
||||
*/
|
||||
router.get('/send_confirmation/pin/:email', async (request: express.Request, response: express.Response): Promise<void> => {
|
||||
const email = request.params.email;
|
||||
|
||||
const pnid = await getPNIDByEmailAddress(email);
|
||||
|
||||
if (!pnid) {
|
||||
// TODO - Unsure if this is the right error
|
||||
response.status(400).send(xmlbuilder.create({
|
||||
errors: {
|
||||
error: {
|
||||
code: '0130',
|
||||
message: 'PID has not been registered yet'
|
||||
}
|
||||
}
|
||||
}).end());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
await sendEmailConfirmedParentalControlsEmail(pnid);
|
||||
|
||||
response.status(200).send('');
|
||||
});
|
||||
|
||||
/**
|
||||
* [GET]
|
||||
* Replacement for: https://account.nintendo.net/v1/api/support/forgotten_password/PID
|
||||
@@ -156,4 +185,4 @@ router.get('/forgotten_password/:pid', async (request: express.Request, response
|
||||
response.status(200).send('');
|
||||
});
|
||||
|
||||
export default router;
|
||||
export default router;
|
||||
|
||||
12
src/util.ts
12
src/util.ts
@@ -224,6 +224,18 @@ export async function sendEmailConfirmedEmail(pnid: mongoose.HydratedDocument<IP
|
||||
await sendMail(options);
|
||||
}
|
||||
|
||||
export async function sendEmailConfirmedParentalControlsEmail(pnid: mongoose.HydratedDocument<IPNID, IPNIDMethods>): Promise<void> {
|
||||
const options = {
|
||||
to: pnid.email.address,
|
||||
subject: '[Pretendo Network] Email address confirmed for Parental Controls',
|
||||
username: pnid.username,
|
||||
paragraph: 'your email address has been confirmed for use with Parental Controls.',
|
||||
text: `Dear ${pnid.username}, \r\n\r\nYour email address has been confirmed for use with Parental Controls.`
|
||||
};
|
||||
|
||||
await sendMail(options);
|
||||
}
|
||||
|
||||
export async function sendForgotPasswordEmail(pnid: mongoose.HydratedDocument<IPNID, IPNIDMethods>): Promise<void> {
|
||||
const tokenOptions = {
|
||||
system_type: 0xF, // * API
|
||||
|
||||
Reference in New Issue
Block a user