Actually set type and userId for codes, don't know what I was thinking
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: localhost
|
||||
-- Generation Time: Jan 24, 2026 at 03:03 AM
|
||||
-- Generation Time: Jan 24, 2026 at 03:57 AM
|
||||
-- Server version: 12.1.2-MariaDB
|
||||
-- PHP Version: 8.5.2
|
||||
|
||||
@@ -94,9 +94,11 @@ CREATE TABLE `loaderupdates` (
|
||||
CREATE TABLE `resetcodes` (
|
||||
`id` bigint(20) NOT NULL,
|
||||
`code` varchar(64) DEFAULT NULL,
|
||||
`userId` bigint(20) NOT NULL,
|
||||
`ip` varchar(255) DEFAULT NULL,
|
||||
`timestamp` bigint(20) NOT NULL,
|
||||
`usedTimestamp` bigint(20) NOT NULL DEFAULT 0
|
||||
`usedTimestamp` bigint(20) NOT NULL DEFAULT 0,
|
||||
`type` int(1) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPRESSED;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
bigint,
|
||||
boolean,
|
||||
int,
|
||||
longtext,
|
||||
mysqlTable,
|
||||
text,
|
||||
@@ -77,11 +78,13 @@ export const verifyCodes = mysqlTable('verifycodes', {
|
||||
export const resetCodes = mysqlTable('resetcodes', {
|
||||
id: bigint('id', { mode: 'number' }).primaryKey().autoincrement().notNull(),
|
||||
code: varchar('code', { length: 64 }).notNull(),
|
||||
userId: bigint('userId', { mode: 'number' }).notNull(),
|
||||
ip: varchar('ip', { length: 255 }),
|
||||
timestamp: bigint('timestamp', { mode: 'number' }).notNull(),
|
||||
usedTimestamp: bigint('usedTimestamp', { mode: 'number' })
|
||||
.default(0)
|
||||
.notNull()
|
||||
.notNull(),
|
||||
type: int('type').notNull()
|
||||
})
|
||||
|
||||
// berrydashdatabase
|
||||
|
||||
@@ -117,9 +117,11 @@ export async function handler (context: Context) {
|
||||
.from(resetCodes)
|
||||
.where(
|
||||
and(
|
||||
eq(resetCodes.userId, result[0].id),
|
||||
eq(resetCodes.ip, ip),
|
||||
eq(resetCodes.usedTimestamp, 0),
|
||||
sql`${resetCodes.timestamp} >= UNIX_TIMESTAMP() - 600`
|
||||
sql`${resetCodes.timestamp} >= UNIX_TIMESTAMP() - 600`,
|
||||
eq(resetCodes.type, 0)
|
||||
)
|
||||
)
|
||||
.orderBy(desc(resetCodes.id))
|
||||
@@ -128,7 +130,9 @@ export async function handler (context: Context) {
|
||||
if (resetCodeExists[0]) {
|
||||
code = resetCodeExists[0].code
|
||||
} else {
|
||||
await db0.insert(resetCodes).values({ code, ip, timestamp: time })
|
||||
await db0
|
||||
.insert(resetCodes)
|
||||
.values({ code, userId: result[0].id, ip, timestamp: time, type: 0 })
|
||||
}
|
||||
|
||||
sendEmail(
|
||||
|
||||
Reference in New Issue
Block a user