Add forgot username/password endpoints that send emails, reset password endpoint will be done next

This commit is contained in:
2026-01-23 20:04:17 -07:00
parent 35d6c5b307
commit ceace4ad8c
9 changed files with 543 additions and 1 deletions

View File

@@ -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', {

View File

@@ -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)
}