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/
|
-- https://www.phpmyadmin.net/
|
||||||
--
|
--
|
||||||
-- Host: localhost
|
-- 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
|
-- Server version: 12.1.2-MariaDB
|
||||||
-- PHP Version: 8.5.2
|
-- PHP Version: 8.5.2
|
||||||
|
|
||||||
@@ -94,9 +94,11 @@ CREATE TABLE `loaderupdates` (
|
|||||||
CREATE TABLE `resetcodes` (
|
CREATE TABLE `resetcodes` (
|
||||||
`id` bigint(20) NOT NULL,
|
`id` bigint(20) NOT NULL,
|
||||||
`code` varchar(64) DEFAULT NULL,
|
`code` varchar(64) DEFAULT NULL,
|
||||||
|
`userId` bigint(20) NOT NULL,
|
||||||
`ip` varchar(255) DEFAULT NULL,
|
`ip` varchar(255) DEFAULT NULL,
|
||||||
`timestamp` bigint(20) NOT 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;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPRESSED;
|
||||||
|
|
||||||
-- --------------------------------------------------------
|
-- --------------------------------------------------------
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
bigint,
|
bigint,
|
||||||
boolean,
|
boolean,
|
||||||
|
int,
|
||||||
longtext,
|
longtext,
|
||||||
mysqlTable,
|
mysqlTable,
|
||||||
text,
|
text,
|
||||||
@@ -77,11 +78,13 @@ export const verifyCodes = mysqlTable('verifycodes', {
|
|||||||
export const resetCodes = mysqlTable('resetcodes', {
|
export const resetCodes = mysqlTable('resetcodes', {
|
||||||
id: bigint('id', { mode: 'number' }).primaryKey().autoincrement().notNull(),
|
id: bigint('id', { mode: 'number' }).primaryKey().autoincrement().notNull(),
|
||||||
code: varchar('code', { length: 64 }).notNull(),
|
code: varchar('code', { length: 64 }).notNull(),
|
||||||
|
userId: bigint('userId', { mode: 'number' }).notNull(),
|
||||||
ip: varchar('ip', { length: 255 }),
|
ip: varchar('ip', { length: 255 }),
|
||||||
timestamp: bigint('timestamp', { mode: 'number' }).notNull(),
|
timestamp: bigint('timestamp', { mode: 'number' }).notNull(),
|
||||||
usedTimestamp: bigint('usedTimestamp', { mode: 'number' })
|
usedTimestamp: bigint('usedTimestamp', { mode: 'number' })
|
||||||
.default(0)
|
.default(0)
|
||||||
.notNull()
|
.notNull(),
|
||||||
|
type: int('type').notNull()
|
||||||
})
|
})
|
||||||
|
|
||||||
// berrydashdatabase
|
// berrydashdatabase
|
||||||
|
|||||||
@@ -117,9 +117,11 @@ export async function handler (context: Context) {
|
|||||||
.from(resetCodes)
|
.from(resetCodes)
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
|
eq(resetCodes.userId, result[0].id),
|
||||||
eq(resetCodes.ip, ip),
|
eq(resetCodes.ip, ip),
|
||||||
eq(resetCodes.usedTimestamp, 0),
|
eq(resetCodes.usedTimestamp, 0),
|
||||||
sql`${resetCodes.timestamp} >= UNIX_TIMESTAMP() - 600`
|
sql`${resetCodes.timestamp} >= UNIX_TIMESTAMP() - 600`,
|
||||||
|
eq(resetCodes.type, 0)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.orderBy(desc(resetCodes.id))
|
.orderBy(desc(resetCodes.id))
|
||||||
@@ -128,7 +130,9 @@ export async function handler (context: Context) {
|
|||||||
if (resetCodeExists[0]) {
|
if (resetCodeExists[0]) {
|
||||||
code = resetCodeExists[0].code
|
code = resetCodeExists[0].code
|
||||||
} else {
|
} 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(
|
sendEmail(
|
||||||
|
|||||||
Reference in New Issue
Block a user