Add forgot username/password endpoints that send emails, reset password endpoint will be done next
This commit is contained in:
@@ -74,6 +74,16 @@ export const verifyCodes = mysqlTable('verifycodes', {
|
||||
.notNull()
|
||||
})
|
||||
|
||||
export const resetCodes = mysqlTable('resetcodes', {
|
||||
id: bigint('id', { mode: 'number' }).primaryKey().autoincrement().notNull(),
|
||||
code: varchar('code', { length: 64 }).notNull(),
|
||||
ip: varchar('ip', { length: 255 }),
|
||||
timestamp: bigint('timestamp', { mode: 'number' }).notNull(),
|
||||
usedTimestamp: bigint('usedTimestamp', { mode: 'number' })
|
||||
.default(0)
|
||||
.notNull()
|
||||
})
|
||||
|
||||
// berrydashdatabase
|
||||
|
||||
export const berryDashUserData = mysqlTable('userdata', {
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
import { Context } from 'elysia'
|
||||
import axios from 'axios'
|
||||
import FormData from 'form-data'
|
||||
import nodemailer from 'nodemailer'
|
||||
|
||||
export function jsonResponse (data: any, status = 200) {
|
||||
return new Response(JSON.stringify(data, null, 2), {
|
||||
@@ -123,3 +124,24 @@ export const validateTurnstile = async (token: string, remoteip: string) => {
|
||||
|
||||
return response.data
|
||||
}
|
||||
|
||||
export const sendEmail = async (to: string, title: string, body: string) => {
|
||||
const transporter = nodemailer.createTransport({
|
||||
service: 'gmail',
|
||||
auth: {
|
||||
user: process.env.GMAIL_USERNAME ?? '',
|
||||
pass: process.env.GMAIL_APP_PASSWORD ?? ''
|
||||
}
|
||||
})
|
||||
|
||||
const mailOptions = {
|
||||
from: `"Lncvrt Games" <${process.env.GMAIL_USERNAME ?? ''}>`,
|
||||
to: to,
|
||||
subject: title,
|
||||
text:
|
||||
body +
|
||||
`\n\nPlease contact ${process.env.GMAIL_USERNAME} if you have any questions or need assistance.`
|
||||
}
|
||||
|
||||
return await transporter.sendMail(mailOptions)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user