Skip to content

Commit

Permalink
fix: It's possible to create infinite empty team
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoRCD committed Oct 11, 2024
1 parent 6f676c0 commit 4389594
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
13 changes: 6 additions & 7 deletions apps/app/app/components/team/Create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,12 @@ async function createTeamFunction(name: string) {
<form @submit.prevent="createTeamFunction(teamName)">
<UCard>
<div class="flex flex-col gap-2">
<p class="flex gap-2 text-sm font-semibold leading-6">
Create a team
</p>
<div class="flex gap-2">
<UInput v-model="teamName" autofocus label="Team name" placeholder="Team name" />
<UButton :loading="createLoading" label="Create" type="submit" />
</div>
<UFormGroup label="Create a team">
<div class="flex gap-2">
<UInput v-model="teamName" required autofocus label="Team name" placeholder="Team name" />
<UButton :loading="createLoading" label="Create" type="submit" />
</div>
</UFormGroup>
</div>
</UCard>
</form>
Expand Down
1 change: 1 addition & 0 deletions apps/app/server/api/teams/index.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { createTeam } from '~~/server/app/teamsService'
export default eventHandler(async (event: H3Event) => {
const { user } = event.context
const createTeamInput = await readBody(event) as CreateTeamInput
if (!createTeamInput.name) throw createError({ statusCode: 400, statusMessage: 'Cannot create team without name' })
createTeamInput.name = createTeamInput.name.trim()
return await createTeam(createTeamInput, user.id)
})

0 comments on commit 4389594

Please sign in to comment.