Translated from English to Dutch

This commit is contained in:
Xeovalyte 2023-05-09 16:01:19 +02:00
parent c668ca7f37
commit 759c4e2bd1
22 changed files with 49 additions and 38 deletions

View File

@ -34,7 +34,7 @@ const submitCode = async () => {
user.value.minecraft.uuid = response.uuid
user.value.minecraft.username = response.username
useToast().success('Successfully whitelisted')
useToast().success('Succesvol gewhitelist')
} catch (e) {
console.log(e);
useToast().error(e.statusMessage)

View File

@ -82,7 +82,7 @@ const leaveTeam = async () => {
user.value.team = null;
useToast().success('Successfully left team')
useToast().success('Succesvol team verlaten')
} catch (e) {
console.log(e);
useToast().error(e.statusMessage)
@ -102,7 +102,7 @@ const editTeam = async () => {
team.value.name = editTeamModal.value.name
team.value.color = editTeamModal.value.color
useToast().success('Successfully modified team')
useToast().success('Team is succesvol bewerkt')
editTeamModal.value.open = false
} catch (e) {
@ -120,7 +120,7 @@ const inviteUser = async (usr) => {
usr.teamInvites.push(user.value.team.id);
useToast().success(`Successfully invited ${usr.username}`)
useToast().success(`Invited ${usr.username} succesvol`)
} catch (e) {
console.log(e);
useToast().error(e.statusMessage)
@ -136,7 +136,7 @@ const cancelInvite = async (usr) => {
usr.teamInvites = usr.teamInvites.filter(a => a !== user.value.team.id);
useToast().success('Successfully cancelled invited')
useToast().success('Succesvol invite geannuleerd')
} catch (e) {
console.log(e);
useToast().error(e.statusMessage)
@ -155,7 +155,7 @@ const promoteUser = async (usr) => {
console.log(usr)
console.log(teamMembers)
useToast().success('Successfully promted user')
useToast().success('Succesvol gebruiker gepromoveerd')
} catch (e) {
console.log(e);
useToast().error(e.statusMessage)
@ -171,7 +171,7 @@ const demoteUser = async (usr) => {
usr.team.admin = false
useToast().success('Successfully demoted user')
useToast().success('Succesvol gebruiker gedegradeerd')
} catch (e) {
console.log(e);
useToast().error(e.statusMessage)

View File

@ -56,11 +56,9 @@ const acceptInvite = async (team) => {
body: { teamId: team._id }
})
console.log(response)
user.value.team = { id: response._id, admin: false }
useToast().success('Successfully joined team')
useToast().success('Succesvol lid geworden van het team')
} catch (e) {
console.log(e);
useToast().error(e.statusMessage)
@ -76,7 +74,7 @@ const handleCreateTeam = async () => {
user.value.team = { id: response.insertedId.toString(), admin: true }
useToast().success('Successfully created team')
useToast().success('Succesvol team gemaakt')
} catch (e) {
console.log(e);

View File

@ -63,7 +63,7 @@ const refreshMinecraftUsername = async () => {
user.value.minecraft.username = response.username
useToast().success('Username is ververst')
useToast().success('Gebruikersnaam is ververst')
} catch (e) {
console.log(e)
@ -77,7 +77,7 @@ const refreshDiscordUsername = async () => {
user.value.discord.username = response.username
useToast().success('Username is ververst')
useToast().success('Gebruikersnaam is ververst')
} catch (e) {
console.log(e)

View File

@ -45,7 +45,7 @@ export default defineEventHandler(async (event) => {
} catch (e) {
console.log(e)
throw createError({ statusCode: 500, statusMessage: 'Error creating login token'})
throw createError({ statusCode: 500, statusMessage: 'Error tijdens het genereren van JWT token'})
}
return sendRedirect(event, '/', 302)

View File

@ -1,5 +1,5 @@
export default defineEventHandler(async (event) => {
const auth = await getAuth(event)
const user = await getAuth(event)
return auth
return user
});

View File

@ -2,7 +2,6 @@ import { ObjectId } from "mongodb";
export default defineEventHandler(async (event) => {
const { type } = await readBody(event)
const auth = await getAuth(event)
const usersColl = db.collection('users')

View File

@ -6,5 +6,5 @@ export default defineEventHandler(async (event) => {
await sendRconCommand(`tellraw @a {"text":"(DC) ${doc.discord.username} > ${content}"}`)
return { whoo: 'hi' }
return { status: 'success' }
});

View File

@ -14,5 +14,5 @@ export default defineEventHandler(async (event) => {
}
})
return { code: 'success' }
return { status: 'success' }
});

View File

@ -1,7 +1,7 @@
export default defineEventHandler(async (event) => {
const auth = await getAuth(event)
if (!auth.minecraft.uuid) throw createError({ errorCode: 400, statusMessage: 'No Minecraft account is linked' })
if (!auth.minecraft.uuid) throw createError({ errorCode: 400, statusMessage: 'Geen Minecraft account is gekoppeld' })
const minecraftProfile = await $fetch(`https://sessionserver.mojang.com/session/minecraft/profile/${auth.minecraft.uuid}`)

View File

@ -1,7 +1,7 @@
export default defineEventHandler(async (event) => {
const auth = await getAuth(event)
if (!auth.minecraft.uuid) throw createError({ errorCode: 400, statusMessage: 'No Minecraft account is linked' })
if (!auth.minecraft.uuid) throw createError({ errorCode: 400, statusMessage: 'Geen Minecraft account is gekoppeld' })
const whitelistColl = db.collection('whitelist')
await whitelistColl.deleteOne({ uuid: auth.minecraft.uuid })

View File

@ -1,14 +1,14 @@
export default defineEventHandler(async (event) => {
const { code } = await readBody(event)
if (!code) throw createError({ statusCode: 400, statusMessage: 'Code is required'})
if (!code) throw createError({ statusCode: 400, statusMessage: 'Code is vereist'})
const auth = await getAuth(event)
const whitelistColl = db.collection('whitelist')
const whitelistDoc = await whitelistColl.findOne({ code: code.toString() })
if (!whitelistDoc) throw createError({ statusCode: 400, statusMessage: 'Code has not been found, join the server first' })
if (!whitelistDoc) throw createError({ statusCode: 400, statusMessage: 'Code is niet gevonden, join eerste de Minecraft server' })
if (whitelistDoc && whitelistDoc.verified) throw createError({ statusCode: 400, statusMessage: 'Already verified' })
await whitelistColl.updateOne({ code: code.toString() }, { $set: { verified: true } })

View File

@ -10,7 +10,7 @@ export default defineEventHandler(async (event) => {
const team = await teamsColl.findOneAndUpdate({ _id: new ObjectId(teamId) }, { $inc: { count: 1 } })
if (!team.value) return createError({ statusCode: 500, statusMessage: 'Could not find team'})
if (!team.value) return createError({ statusCode: 500, statusMessage: 'Team niet gevonden'})
await usersColl.updateOne({ _id: new ObjectId(user._id) }, { $set: { 'team.id': teamId, 'team.admin': false }})

View File

@ -1,17 +1,18 @@
export default defineEventHandler(async (event) => {
const { teamName, teamColor } = await readBody(event);
if (!teamName || !teamColor) return createError({ statusCode: 400, statusMessage: 'teamName and teamColor are required' })
if (!isHexColor(teamColor)) return createError({ statusCode: 400, statusMessage: 'Team color is not a valid hex code' })
if (!teamName || !teamColor) return createError({ statusCode: 400, statusMessage: 'Team naam en kleur zijn vereist' })
if (!isHexColor(teamColor)) return createError({ statusCode: 400, statusMessage: 'Team kleur is geen gelidige kleurencode' })
if (!verifyUsername(teamName)) return createError({ statusCode: 400, statusMessage: 'Team naam moet alfanumeriek zijn en mag maximaal 20 tekens lang zijn' })
const user = await getAuth(event)
if (user.team) return createError({ statusCode: 400, statusMessage: 'User already is in a team' })
if (user.team) return createError({ statusCode: 400, statusMessage: 'Gebruiker is al in een team' })
const teamsColl = db.collection('teams')
const usersColl = db.collection('users')
if (await teamsColl.findOne({ name: teamName })) return createError({ statusCode: 400, statusMessage: 'Team name already exists' })
if (await teamsColl.findOne({ name: { $regex: new RegExp(teamName, "i") } })) return createError({ statusCode: 400, statusMessage: 'Team naam bestaat al' })
const response = await teamsColl.insertOne({ name: teamName, color: teamColor, count: 1 })

View File

@ -5,7 +5,7 @@ export default defineEventHandler(async (event) => {
const user = await getAuth(event)
if (!user.team.admin) return createError({ statusCode: 403, statusMessage: 'Forbidden' })
if (!user.team.admin) return createError({ statusCode: 403, statusMessage: 'Admin team rol vereist' })
const usersColl = db.collection('users')
await usersColl.findOneAndUpdate({ _id: new ObjectId(userId) }, { $set: { 'team.admin': false } });

View File

@ -3,7 +3,9 @@ import { ObjectId } from 'mongodb'
export default defineEventHandler(async (event) => {
const { name, color } = await readBody(event);
if (!isHexColor(color)) return createError({ statusCode: 400, statusMessage: 'Team color is not a valid hex code' })
if (!name || !color) return createError({ statusCode: 400, statusMessage: 'Team naam en kleur zijn vereist' })
if (!isHexColor(color)) return createError({ statusCode: 400, statusMessage: 'Team kleur is geen goede kleurencode' })
if (!verifyUsername(name)) return createError({ statusCode: 400, statusMessage: 'Team naam moet alfanumeriek zijn en mag maximaal 20 tekens lang zijn' })
const user = await getAuth(event)
@ -11,7 +13,7 @@ export default defineEventHandler(async (event) => {
const team = await teamsColl.findOne({ _id: new ObjectId(user.team.id) });
if (team.name !== name && await teamsColl.findOne({ name: name })) return createError({ statusCode: 400, statusMessage: 'Team name already exists' })
if (team.name !== name && await teamsColl.findOne({ name: { $regex: new RegExp(name, "i") } })) return createError({ statusCode: 400, statusMessage: 'Team naam bestaat al' })
await teamsColl.updateOne({ _id: new ObjectId(user.team.id) }, { $set: { name: name, color: color } })

View File

@ -12,7 +12,7 @@ export default defineEventHandler(async (event) => {
const invitedUser = await usersColl.findOne({ _id: new ObjectId(id)});
if (invitedUser.team) return createError({ statusCode: 400, statusMessage: 'User already is in a team' })
if (invitedUser.team) return createError({ statusCode: 400, statusMessage: 'Gebruiker zit al in een team' })
usersColl.updateOne({ _id: new ObjectId(id) }, { $push: { teamInvites: team._id.toString() } })

View File

@ -5,7 +5,7 @@ export default defineEventHandler(async (event) => {
const cursor = usersColl.find({ 'team.id': user.team.id })
if((await usersColl.countDocuments({ 'team.id': user.team.id })) === 0) {
return createError({ statusCode: 500, statusMessage: 'No users were found' })
return createError({ statusCode: 500, statusMessage: 'Geen gebruikers zijn gevonden' })
}
const users = [];

View File

@ -5,7 +5,7 @@ export default defineEventHandler(async (event) => {
const user = await getAuth(event)
if (!user.team.admin) return createError({ statusCode: 403, statusMessage: 'Forbidden' })
if (!user.team.admin) return createError({ statusCode: 403, statusMessage: 'Admin team rol is vereist' })
const usersColl = db.collection('users')
await usersColl.findOneAndUpdate({ _id: new ObjectId(userId) },{ $set: { 'team.admin': true } });

View File

@ -1,4 +1,4 @@
export default defineEventHandler(async (event) => {
export default defineEventHandler(async () => {
const usersColl = db.collection('users')
const cursor = usersColl.find({ team: { $exists: false } })
const unaffiliatedUsers = await cursor.toArray()

View File

@ -14,7 +14,7 @@ export const getAuth = async (event) => {
if (!token) {
throw createError({
statusCode: 401,
statusMessage: 'JWT token invalid',
statusMessage: 'JWT token is niet geldig',
})
}
@ -28,7 +28,7 @@ export const getAuth = async (event) => {
throw createError({
statusCode: 401,
statusMessage: 'JWT token invalid',
statusMessage: 'JWT token is niet geldig',
})
}
@ -44,7 +44,7 @@ export const getAuth = async (event) => {
throw createError({
statusCode: 500,
statusMessage: 'Error getting user'
statusMessage: 'Error tijdens ophalen van gegevens'
})
}
}

View File

@ -2,3 +2,14 @@ export const isHexColor = (str) => {
const pattern = /^#([0-9A-F]{3}){1,2}$/i;
return pattern.test(str);
}
export const verifyUsername = (username) => {
const alphanumeric = /^[a-zA-Z0-9]+$/;
if (username.length > 20) {
return false;
}
if (!alphanumeric.test(username)) {
return false;
}
return true;
}