rename cracked to noauth and remove the possibility to self register as such

This commit is contained in:
bytedream 2023-11-13 11:42:24 +01:00
parent 241d6c031e
commit 4a4135c31e
9 changed files with 17 additions and 30 deletions

View File

@ -27,8 +27,8 @@ export class User extends Model {
declare telephone: string;
@Column({ type: DataTypes.STRING, allowNull: false })
declare username: string;
@Column({ type: DataTypes.ENUM('java', 'bedrock', 'cracked'), allowNull: false })
declare playertype: 'java' | 'bedrock' | 'cracked';
@Column({ type: DataTypes.ENUM('java', 'bedrock', 'noauth'), allowNull: false })
declare playertype: 'java' | 'bedrock' | 'noauth';
@Column({ type: DataTypes.STRING })
declare password: string;
@Column({ type: DataTypes.UUIDV4 })
@ -47,7 +47,7 @@ export class Report extends Model {
declare body: string;
@Column({ type: DataTypes.BOOLEAN, allowNull: false })
declare draft: boolean;
@Column({ type: DataTypes.ENUM('java', 'bedrock', 'cracked'), allowNull: false })
@Column({ type: DataTypes.ENUM('java', 'bedrock', 'noauth'), allowNull: false })
declare status: 'none' | 'review' | 'reviewed';
@Column({ type: DataTypes.STRING })
declare notice: string;

View File

@ -1,5 +1,5 @@
import { describe, expect, test } from 'vitest';
import { getBedrockUuid, getCrackedUuid, getJavaUuid } from '$lib/server/minecraft';
import { getBedrockUuid, getJavaUuid, getNoAuthUuid } from '$lib/server/minecraft';
describe('java username', () => {
test('is valid', async () => {
@ -19,9 +19,9 @@ describe('bedrock username', () => {
});
});
describe('cracked username', () => {
describe('noauth username', () => {
// every username can be converted to an uuid so every user id automatically valid
test('is valid', () => {
expect(getCrackedUuid('bytedream')).toBe('88de3863-bf47-30f9-a7f4-ab6134feb49a');
expect(getNoAuthUuid('bytedream')).toBe('88de3863-bf47-30f9-a7f4-ab6134feb49a');
});
});

View File

@ -68,7 +68,7 @@ export async function getBedrockUuid(username: string): Promise<string> {
}
// https://gist.github.com/yushijinhun/69f68397c5bb5bee76e80d192295f6e0
export function getCrackedUuid(username: string): string {
export function getNoAuthUuid(username: string): string {
const data = createHash('md5').update(`OfflinePlayer:${username}`).digest('binary').split('');
data[6] = String.fromCharCode((data[6].charCodeAt(0) & 0x0f) | 0x30);
data[8] = String.fromCharCode((data[8].charCodeAt(0) & 0x3f) | 0x80);

View File

@ -147,7 +147,7 @@
<Select id="edition" bind:value={user.playertype} disabled={!user.edit} size="sm">
<option value="java">Java Edition</option>
<option value="bedrock">Bedrock Edition</option>
<option value="cracked">Java cracked</option>
<option value="noauth">Java noauth</option>
</Select>
</td>
<td>

View File

@ -16,7 +16,7 @@ export const POST = (async ({ request, cookies }) => {
from: number | null;
name: string | null;
playertype: 'java' | 'bedrock' | 'cracked' | null;
playertype: 'java' | 'bedrock' | 'noauth' | null;
search: string | null;
slim: boolean | null;

View File

@ -19,7 +19,7 @@
<option value={null}>Alle</option>
<option value="java">Java</option>
<option value="beckdrock">Bedrock</option>
<option value="cracked">Cracked</option>
<option value="noauth">Noauth</option>
</Select>
</div>
</form>

View File

@ -1,7 +1,7 @@
import {
getBedrockUuid,
getCrackedUuid,
getJavaUuid,
getNoAuthUuid,
UserNotFoundError
} from '$lib/server/minecraft';
import { error, type RequestHandler } from '@sveltejs/kit';
@ -12,7 +12,7 @@ export const POST = (async ({ request }) => {
let uuid: string;
try {
// available playertypes are 'java', 'bedrock' and 'cracked'
// available playertypes are 'java', 'bedrock' and 'noauth'
switch (data.get('playertype')) {
case 'java':
uuid = await getJavaUuid(data.get('username') as string);
@ -20,8 +20,8 @@ export const POST = (async ({ request }) => {
case 'bedrock':
uuid = await getBedrockUuid(data.get('username') as string);
break;
case 'cracked':
uuid = getCrackedUuid(data.get('username') as string);
case 'noauth':
uuid = getNoAuthUuid(data.get('username') as string);
break;
default:
throw new Error(`invalid player type (${data.get('playertype')})`);

View File

@ -122,22 +122,7 @@
>
<option value="java">Java Edition</option>
<option value="bedrock">Bedrock Edition</option>
<option value="cracked">Java cracked</option>
</Select>
{#if playertype === 'cracked'}
<div class="sm:col-span-2">
<Input id="password" name="password" type="password" required={true}>
<span slot="label">Passwort</span>
<span slot="notice">
Da Du cracked spielst, musst Du ein Passwort festlegen, mit welchem Du Dich auf dem
Server authentifizierst! Das Passwort wird im Klartext gespeichert und ist in deinen
Clientlogs sowie in Serverlogs für Admins sichtbar. Verwende daher ein neues Passwort,
welches Du nirgends sonst verwendest! Merke Dir das Passwort gut, ohne kannst Du Dich
nicht auf dem Server einloggen
</span>
</Input>
</div>
{/if}
</div>
<div class="divider" />
<div class="mx-2 grid gap-y-3 mb-6">

View File

@ -13,7 +13,9 @@ export const POST = (async ({ request, url }) => {
if (data.reporter == null || data.reason == null) return new Response(null, { status: 400 });
const reporter = await User.findOne({ where: { uuid: data.reporter } });
const reported = data.reported ? await User.findOne({ where: { uuid: data.reported } }) : undefined;
const reported = data.reported
? await User.findOne({ where: { uuid: data.reported } })
: undefined;
if (reporter == null || reported === null) return new Response(null, { status: 400 });