From 3d2e114588eb55965eea75f99798dd5be8d0ef20 Mon Sep 17 00:00:00 2001 From: Zisu Zhang Date: Wed, 24 Jan 2024 05:19:14 +0800 Subject: [PATCH] chore: cumulative update for ux improvements (#39) 1. Added more status colors 2. Fixed username length for malicious user --- .yarn/versions/2330b447.yml | 3 +++ .../src/components/solution/SolutionStateChip.vue | 2 +- .../src/components/solution/SolutionStatusChip.vue | 4 +++- apps/server/src/auth/mail.ts | 10 ++++++++-- apps/server/src/schemas/user.ts | 10 +++++----- 5 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 .yarn/versions/2330b447.yml diff --git a/.yarn/versions/2330b447.yml b/.yarn/versions/2330b447.yml new file mode 100644 index 0000000..85ee0e5 --- /dev/null +++ b/.yarn/versions/2330b447.yml @@ -0,0 +1,3 @@ +releases: + "@aoi-js/frontend": patch + "@aoi-js/server": patch diff --git a/apps/frontend/src/components/solution/SolutionStateChip.vue b/apps/frontend/src/components/solution/SolutionStateChip.vue index e718962..006a105 100644 --- a/apps/frontend/src/components/solution/SolutionStateChip.vue +++ b/apps/frontend/src/components/solution/SolutionStateChip.vue @@ -16,7 +16,7 @@ const stateMap = { 0: ['created', 'mdi-moon-new', 'grey'], 1: ['pending', 'mdi-timer-sand', 'orange'], 2: ['queued', 'mdi-cloud-outline', 'blue'], - 3: ['running', 'mdi-play', 'green'], + 3: ['running', 'mdi-play', 'indigo'], 4: ['completed', 'mdi-check', 'success'] } as const const state = computed(() => stateMap[props.state as never] ?? ['unknown', 'mdi-help', 'grey']) diff --git a/apps/frontend/src/components/solution/SolutionStatusChip.vue b/apps/frontend/src/components/solution/SolutionStatusChip.vue index 332b554..135aa35 100644 --- a/apps/frontend/src/components/solution/SolutionStatusChip.vue +++ b/apps/frontend/src/components/solution/SolutionStatusChip.vue @@ -25,7 +25,9 @@ const knownStatus: Record = { 'Time Limit Exceeded': ['mdi-timer-alert-outline', 'error'], 'Wrong Answer': ['mdi-close', 'error'], 'Compile Error': ['mdi-code-braces', 'error'], - 'Internal Error': ['mdi-help-circle-outline', ''] + 'Internal Error': ['mdi-help-circle-outline', ''], + 'Runtime Error': ['mdi-alert-decagram-outline', 'error'], + Running: ['mdi-play', 'indigo'] } const display = computed(() => knownStatus[props.status] ?? ['mdi-circle-outline', 'warning']) diff --git a/apps/server/src/auth/mail.ts b/apps/server/src/auth/mail.ts index 1d6edb2..f576844 100644 --- a/apps/server/src/auth/mail.ts +++ b/apps/server/src/auth/mail.ts @@ -10,7 +10,10 @@ import { cache } from '../cache/index.js' import { httpErrors } from '@fastify/sensible' const SEmailPayload = Type.Object({ - email: Type.String({ pattern: '^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$' }) + email: Type.String({ + maxLength: 128, + pattern: '^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$' + }) }) const EmailPayload = TypeCompiler.Compile(SEmailPayload) @@ -22,7 +25,10 @@ const SCodePayload = Type.Object({ const CodePayload = TypeCompiler.Compile(SCodePayload) const SLoginPayload = Type.Object({ - email: Type.String({ pattern: '^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$' }), + email: Type.String({ + maxLength: 128, + pattern: '^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$' + }), code: Type.String({ pattern: '^[0-9]{6}$' }) }) diff --git a/apps/server/src/schemas/user.ts b/apps/server/src/schemas/user.ts index 8d23a22..07fe1c2 100644 --- a/apps/server/src/schemas/user.ts +++ b/apps/server/src/schemas/user.ts @@ -1,12 +1,12 @@ import { Type, Static } from '@sinclair/typebox' export const SUserProfile = Type.StrictObject({ - name: Type.String(), - email: Type.String({ pattern: '^\\S+@\\S+$' }), - realname: Type.String(), + name: Type.String({ maxLength: 16 }), + email: Type.String({ maxLength: 128, pattern: '^\\S+@\\S+$' }), + realname: Type.String({ maxLength: 16 }), telephone: Type.Optional(Type.String({ pattern: '^\\d{11}$' })), - school: Type.Optional(Type.String()), - studentGrade: Type.Optional(Type.String()), + school: Type.Optional(Type.String({ maxLength: 32 })), + studentGrade: Type.Optional(Type.String({ maxLength: 32 })), verified: Type.Optional(Type.Array(Type.String())) })