Compare commits

..

No commits in common. "d74a51db7f9623cbd8e1a5860e523890241ab5e3" and "12e92b8106e22e6174c3bb2491974ecb8570098c" have entirely different histories.

6 changed files with 4 additions and 43 deletions

View File

@ -4,9 +4,9 @@ export default defineNuxtRouteMiddleware(async (to) => {
}
try {
const user = await $fetch('/api/users/@me')
const user = await $fetch('/api/auth/user')
if (!user._id) {
if (!user.id) {
throw createError({ statusCode: 500, statusMessage: 'No user was found' })
}

View File

@ -1,4 +1,4 @@
import jwt from 'jsonwebtoken' //eslint-disable-line
import * as jwt from 'jsonwebtoken'
type AccessTokenResponse = {
access_token: string,

View File

@ -1,24 +0,0 @@
export default defineEventHandler(async (event) => {
const { uuid } = getQuery(event)
let whitelistDoc
try {
whitelistDoc = await WhitelistModel.findOneAndUpdate({ uuid }, {
$set: {
uuid
},
$setOnInsert: {
code: generateCode(),
connected: false
}
}, { returnDocument: 'after', upsert: true })
return whitelistDoc
} catch (e: any) {
throw createError({ statusCode: 500, statusMessage: 'Failed to update/insert whitelist document' })
}
})
const generateCode = () => {
return Math.floor(100000 + Math.random() * 900000)
}

View File

@ -21,11 +21,4 @@ const userSchema = new Schema({
]
})
const whitelistSchema = new Schema({
uuid: { type: String, required: true, unique: true },
connected: { type: Boolean, required: true, default: false },
code: { type: String, required: true, unique: true, length: 6 }
})
export const UserModel = model<IUser>('User', userSchema)
export const WhitelistModel = model<IWhitelist>('Whitelist', whitelistSchema)

View File

@ -3,6 +3,5 @@
"extends": "./.nuxt/tsconfig.json",
"compilerOptions": {
"typeRoots": ["./types"]
},
"esModuleInterop": true
}
}

View File

@ -21,11 +21,4 @@ declare global {
teamId: string,
accessToken?: string
}
interface IWhitelist {
_id: string,
uuid: string,
connected: boolean,
code: string
}
}