Add admin flag to savefile
This commit is contained in:
4 files changed
+8
-4
No files matched your search
@@ -3,9 +3,9 @@
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: localhost
|
||||
-- Generation Time: Feb 13, 2026 at 09:50 AM
|
||||
-- Server version: 11.8.5-MariaDB-log
|
||||
-- PHP Version: 8.5.2
|
||||
-- Generation Time: Feb 22, 2026 at 03:13 PM
|
||||
-- Server version: 11.8.6-MariaDB-log
|
||||
-- PHP Version: 8.5.3
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
START TRANSACTION;
|
||||
@@ -120,6 +120,7 @@ CREATE TABLE `users` (
|
||||
`token` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
|
||||
`latest_ip` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
|
||||
`register_time` bigint(20) NOT NULL,
|
||||
`admin` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`leaderboards_banned` tinyint(1) NOT NULL DEFAULT 0
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=COMPRESSED;
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ export const users = mysqlTable('users', {
|
||||
token: varchar('token', { length: 512 }).notNull(),
|
||||
latestIp: varchar('latest_ip', { length: 255 }),
|
||||
registerTime: bigint('register_time', { mode: 'number' }).notNull(),
|
||||
admin: boolean('admin').default(false).notNull(),
|
||||
leaderboardsBanned: boolean('leaderboards_banned').default(false).notNull()
|
||||
})
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ export const handler = async (context: Context) => {
|
||||
.where(eq(berryDashUserData.id, userId))
|
||||
.execute()
|
||||
const result2 = await db0
|
||||
.select({ username: users.username })
|
||||
.select({ username: users.username, admin: users.admin })
|
||||
.from(users)
|
||||
.where(eq(users.id, userId))
|
||||
.execute()
|
||||
@@ -64,6 +64,7 @@ export const handler = async (context: Context) => {
|
||||
savedata.account.id = userId
|
||||
savedata.account.name = result2[0].username
|
||||
savedata.account.session = authorizationToken
|
||||
if (result2[0].admin) savedata.account.admin = true
|
||||
if (savedata.version != '1') {
|
||||
savedata.version = '1'
|
||||
if (savedata.bird.customIcon.data) {
|
||||
|
||||
@@ -47,6 +47,7 @@ export const handler = async (context: Context) => {
|
||||
userSaveData.account.id = null
|
||||
userSaveData.account.name = null
|
||||
userSaveData.account.session = null
|
||||
if (userSaveData.account.admin) delete userSaveData.account.admin
|
||||
} catch {
|
||||
connection0.end()
|
||||
connection1.end()
|
||||
|
||||
Reference in new issue
Block a user