Move from storing tokens in Berry Dash Database to Lncvrt Games Database
This commit is contained in:
@@ -4,7 +4,7 @@ import {
|
||||
getDatabaseConnection,
|
||||
jsonResponse
|
||||
} from '../../../../lib/util'
|
||||
import { checkAuthorization } from '../../../../lib/bd/auth'
|
||||
import { checkAuthorization } from '../../../../lib/auth'
|
||||
import { users } from '../../../../lib/tables'
|
||||
import { eq } from 'drizzle-orm'
|
||||
import bcrypt from 'bcryptjs'
|
||||
@@ -29,7 +29,6 @@ export async function handler (context: Context) {
|
||||
const authorizationToken = context.headers.authorization
|
||||
const authResult = await checkAuthorization(
|
||||
authorizationToken as string,
|
||||
db1,
|
||||
db0,
|
||||
ip
|
||||
)
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
getDatabaseConnection,
|
||||
jsonResponse
|
||||
} from '../../../../lib/util'
|
||||
import { checkAuthorization } from '../../../../lib/bd/auth'
|
||||
import { checkAuthorization } from '../../../../lib/auth'
|
||||
import { users } from '../../../../lib/tables'
|
||||
import { eq } from 'drizzle-orm'
|
||||
|
||||
@@ -28,7 +28,6 @@ export async function handler (context: Context) {
|
||||
const authorizationToken = context.headers.authorization
|
||||
const authResult = await checkAuthorization(
|
||||
authorizationToken as string,
|
||||
db1,
|
||||
db0,
|
||||
ip
|
||||
)
|
||||
|
||||
@@ -39,7 +39,8 @@ export async function handler (context: Context) {
|
||||
.select({
|
||||
id: users.id,
|
||||
username: users.username,
|
||||
password: users.password
|
||||
password: users.password,
|
||||
token: users.token
|
||||
})
|
||||
.from(users)
|
||||
.where(eq(users.username, body.username))
|
||||
@@ -70,30 +71,11 @@ export async function handler (context: Context) {
|
||||
)
|
||||
}
|
||||
|
||||
const user2 = await db1
|
||||
.select({ token: berryDashUserData.token })
|
||||
.from(berryDashUserData)
|
||||
.where(eq(berryDashUserData.id, user[0].id))
|
||||
.limit(1)
|
||||
.execute()
|
||||
if (!user2[0]) {
|
||||
connection0.end()
|
||||
connection1.end()
|
||||
return jsonResponse(
|
||||
{
|
||||
success: false,
|
||||
message: 'Invalid username or password',
|
||||
data: null
|
||||
},
|
||||
401
|
||||
)
|
||||
}
|
||||
|
||||
return jsonResponse({
|
||||
success: true,
|
||||
message: null,
|
||||
data: {
|
||||
session: user2[0].token,
|
||||
session: user[0].token,
|
||||
username: user[0].username,
|
||||
id: user[0].id
|
||||
}
|
||||
|
||||
@@ -156,6 +156,7 @@ export async function handler (context: Context) {
|
||||
username: body.username,
|
||||
password: hashedPassword,
|
||||
email: body.email,
|
||||
token,
|
||||
registerTime: time,
|
||||
latestIp: ip
|
||||
})
|
||||
@@ -164,8 +165,7 @@ export async function handler (context: Context) {
|
||||
await db1
|
||||
.insert(berryDashUserData)
|
||||
.values({
|
||||
id: result[0].insertId,
|
||||
token
|
||||
id: result[0].insertId
|
||||
})
|
||||
.execute()
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
getDatabaseConnection,
|
||||
jsonResponse
|
||||
} from '../../../../lib/util'
|
||||
import { checkAuthorization } from '../../../../lib/bd/auth'
|
||||
import { checkAuthorization } from '../../../../lib/auth'
|
||||
import { berryDashUserData, users } from '../../../../lib/tables'
|
||||
import { eq } from 'drizzle-orm'
|
||||
|
||||
@@ -24,7 +24,6 @@ export async function handler (context: Context) {
|
||||
const authorizationToken = context.headers.authorization
|
||||
const authResult = await checkAuthorization(
|
||||
authorizationToken as string,
|
||||
db1,
|
||||
db0,
|
||||
ip
|
||||
)
|
||||
@@ -40,8 +39,7 @@ export async function handler (context: Context) {
|
||||
|
||||
const result = await db1
|
||||
.select({
|
||||
saveData: berryDashUserData.saveData,
|
||||
token: berryDashUserData.token
|
||||
saveData: berryDashUserData.saveData
|
||||
})
|
||||
.from(berryDashUserData)
|
||||
.where(eq(berryDashUserData.id, userId))
|
||||
@@ -65,6 +63,6 @@ export async function handler (context: Context) {
|
||||
if (!savedata.account) savedata.account = {}
|
||||
savedata.account.id = userId
|
||||
savedata.account.name = result2[0].username
|
||||
savedata.account.session = result[0].token
|
||||
savedata.account.session = authorizationToken
|
||||
return jsonResponse({ success: true, message: null, data: savedata }, 200)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
getDatabaseConnection,
|
||||
jsonResponse
|
||||
} from '../../../../lib/util'
|
||||
import { checkAuthorization } from '../../../../lib/bd/auth'
|
||||
import { checkAuthorization } from '../../../../lib/auth'
|
||||
import { berryDashUserData } from '../../../../lib/tables'
|
||||
import { eq } from 'drizzle-orm'
|
||||
|
||||
@@ -28,7 +28,6 @@ export async function handler (context: Context) {
|
||||
const authorizationToken = context.headers.authorization
|
||||
const authResult = await checkAuthorization(
|
||||
authorizationToken as string,
|
||||
db1,
|
||||
db0,
|
||||
ip
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
jsonResponse
|
||||
} from '../../../../lib/util'
|
||||
import { berryDashChatroomReports } from '../../../../lib/tables'
|
||||
import { checkAuthorization } from '../../../../lib/bd/auth'
|
||||
import { checkAuthorization } from '../../../../lib/auth'
|
||||
import { and, eq } from 'drizzle-orm'
|
||||
|
||||
type Body = {
|
||||
@@ -29,7 +29,6 @@ export async function handler (context: Context) {
|
||||
const authorizationToken = context.headers.authorization
|
||||
const authResult = await checkAuthorization(
|
||||
authorizationToken as string,
|
||||
db1,
|
||||
db0,
|
||||
ip
|
||||
)
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
} from '../../../lib/util'
|
||||
import { berryDashMarketplaceIcons, users } from '../../../lib/tables'
|
||||
import { and, eq, inArray, or, sql, not, desc, asc } from 'drizzle-orm'
|
||||
import { checkAuthorization } from '../../../lib/bd/auth'
|
||||
import { checkAuthorization } from '../../../lib/auth'
|
||||
|
||||
type Body = {
|
||||
sortBy: number
|
||||
@@ -49,7 +49,6 @@ export async function handler (context: Context) {
|
||||
const authorizationToken = context.headers.authorization
|
||||
const authResult = await checkAuthorization(
|
||||
authorizationToken as string,
|
||||
db1,
|
||||
db0,
|
||||
ip
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
hash,
|
||||
jsonResponse
|
||||
} from '../../../../lib/util'
|
||||
import { checkAuthorization } from '../../../../lib/bd/auth'
|
||||
import { checkAuthorization } from '../../../../lib/auth'
|
||||
import { berryDashMarketplaceIcons, verifyCodes } from '../../../../lib/tables'
|
||||
import { and, desc, eq, sql } from 'drizzle-orm'
|
||||
import { Buffer } from 'buffer'
|
||||
@@ -61,7 +61,6 @@ export async function handler (context: Context) {
|
||||
const authorizationToken = context.headers.authorization
|
||||
const authResult = await checkAuthorization(
|
||||
authorizationToken as string,
|
||||
db1,
|
||||
db0,
|
||||
ip
|
||||
)
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
} from '../../../../lib/util'
|
||||
import { berryDashUserPosts } from '../../../../lib/tables'
|
||||
import { and, eq } from 'drizzle-orm'
|
||||
import { checkAuthorization } from '../../../../lib/bd/auth'
|
||||
import { checkAuthorization } from '../../../../lib/auth'
|
||||
|
||||
export async function handler (context: Context) {
|
||||
const dbInfo0 = getDatabaseConnection(0)
|
||||
@@ -24,7 +24,6 @@ export async function handler (context: Context) {
|
||||
const authorizationToken = context.headers.authorization
|
||||
const authResult = await checkAuthorization(
|
||||
authorizationToken as string,
|
||||
db1,
|
||||
db0,
|
||||
ip
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
jsonResponse
|
||||
} from '../../../../lib/util'
|
||||
import { berryDashUserPosts } from '../../../../lib/tables'
|
||||
import { checkAuthorization } from '../../../../lib/bd/auth'
|
||||
import { checkAuthorization } from '../../../../lib/auth'
|
||||
|
||||
type Body = {
|
||||
content: string
|
||||
@@ -27,7 +27,6 @@ export async function handler (context: Context) {
|
||||
const authorizationToken = context.headers.authorization
|
||||
const authResult = await checkAuthorization(
|
||||
authorizationToken as string,
|
||||
db1,
|
||||
db0,
|
||||
ip
|
||||
)
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
} from '../../../../lib/util'
|
||||
import { berryDashUserPosts } from '../../../../lib/tables'
|
||||
import { and, eq } from 'drizzle-orm'
|
||||
import { checkAuthorization } from '../../../../lib/bd/auth'
|
||||
import { checkAuthorization } from '../../../../lib/auth'
|
||||
|
||||
export async function handler (context: Context) {
|
||||
const dbInfo0 = getDatabaseConnection(0)
|
||||
@@ -24,7 +24,6 @@ export async function handler (context: Context) {
|
||||
const authorizationToken = context.headers.authorization
|
||||
const authResult = await checkAuthorization(
|
||||
authorizationToken as string,
|
||||
db1,
|
||||
db0,
|
||||
ip
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user