Add get-verify-code endpoint
This commit is contained in:
@@ -65,6 +65,14 @@ export const launcherVersionManifest = mysqlTable('launcherversionmanifest', {
|
||||
changelog: text('changelog')
|
||||
})
|
||||
|
||||
export const verifyCodes = mysqlTable('verifycodes', {
|
||||
id: int('id').primaryKey().autoincrement().notNull(),
|
||||
code: varchar('code', { length: 16 }).notNull(),
|
||||
ip: varchar('ip', { length: 255 }),
|
||||
timestamp: int('timestamp').notNull(),
|
||||
used: boolean('used').default(false).notNull()
|
||||
})
|
||||
|
||||
// berrydashdatabase
|
||||
|
||||
export const berryDashUserData = mysqlTable('userdata', {
|
||||
|
||||
@@ -7,6 +7,8 @@ import {
|
||||
latestVersion
|
||||
} from '../info/general'
|
||||
import { Context } from 'elysia'
|
||||
import axios from 'axios'
|
||||
import FormData from 'form-data'
|
||||
|
||||
export function jsonResponse (data: any, status = 200) {
|
||||
return new Response(JSON.stringify(data, null, 2), {
|
||||
@@ -104,3 +106,20 @@ export const getClientIp = (context: Context) => {
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
export const validateTurnstile = async (token: string, remoteip: string) => {
|
||||
const form = new FormData()
|
||||
form.append('secret', process.env.TURNSTILE_SECRET_KEY!)
|
||||
form.append('response', token)
|
||||
form.append('remoteip', remoteip)
|
||||
|
||||
const response = await axios.post(
|
||||
'https://challenges.cloudflare.com/turnstile/v0/siteverify',
|
||||
form,
|
||||
{
|
||||
headers: form.getHeaders()
|
||||
}
|
||||
)
|
||||
|
||||
return response.data
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user