Skip to content
Snippets Groups Projects
Commit 2dee4db9 authored by Daniel Gerdes's avatar Daniel Gerdes
Browse files

Refactor naming scheme

parent da39c774
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,7 @@ generator client { ...@@ -10,7 +10,7 @@ generator client {
model Group { model Group {
id String @id @default(uuid()) id String @id @default(uuid())
name String @unique name String @unique
code String @unique slug String @unique
tokens Int @default(0) tokens Int @default(0)
unlocks Entry[] unlocks Entry[]
......
...@@ -17,7 +17,7 @@ export class GroupAuthGuard implements CanActivate { ...@@ -17,7 +17,7 @@ export class GroupAuthGuard implements CanActivate {
if (!token) return false; if (!token) return false;
req.group = await this.prismaService.group.findFirst({ req.group = await this.prismaService.group.findFirst({
where: { code: token }, where: { slug: token },
}); });
return !!req.group; return !!req.group;
......
...@@ -14,7 +14,7 @@ export class WebAuthGuard implements CanActivate { ...@@ -14,7 +14,7 @@ export class WebAuthGuard implements CanActivate {
if (!token) throw new UnauthorizedException(); if (!token) throw new UnauthorizedException();
const group = await this.prismaService.group.findFirst({ const group = await this.prismaService.group.findFirst({
where: { code: token }, where: { slug: token },
}); });
if (!group) throw new ForbiddenException(); if (!group) throw new ForbiddenException();
......
...@@ -27,14 +27,14 @@ export class GroupResolver { ...@@ -27,14 +27,14 @@ export class GroupResolver {
payload.updateToken.code === variables.groupCode, payload.updateToken.code === variables.groupCode,
}) })
async updateToken( async updateToken(
@Args({ name: 'groupCode', type: () => GraphQLString }) @Args({ name: 'groupSlug', type: () => GraphQLString })
groupCode: string, groupSlug: string,
) { ) {
if (!groupCode) throw new UnauthorizedException(); if (!groupSlug) throw new UnauthorizedException();
const group = await this.prismaService.group.findFirst({ const group = await this.prismaService.group.findFirst({
where: { where: {
code: groupCode, slug: groupSlug,
}, },
}); });
...@@ -45,11 +45,11 @@ export class GroupResolver { ...@@ -45,11 +45,11 @@ export class GroupResolver {
@Mutation(() => Group) @Mutation(() => Group)
async addToken( async addToken(
@Args({ name: 'code', type: () => GraphQLString }) code: string, @Args({ name: 'groupSlug', type: () => GraphQLString }) groupSlug: string,
) { ) {
const group = await this.prismaService.group.update({ const group = await this.prismaService.group.update({
where: { where: {
code: code, slug: groupSlug,
}, },
data: { data: {
tokens: { increment: 1 }, tokens: { increment: 1 },
...@@ -84,7 +84,7 @@ export class GroupResolver { ...@@ -84,7 +84,7 @@ export class GroupResolver {
return seedWords[Math.round(Math.random() * seedWords.length)]; return seedWords[Math.round(Math.random() * seedWords.length)];
} }
const code = [ const slug = [
generateWord(), generateWord(),
generateWord(), generateWord(),
generateWord(), generateWord(),
...@@ -94,7 +94,7 @@ export class GroupResolver { ...@@ -94,7 +94,7 @@ export class GroupResolver {
return this.prismaService.group.create({ return this.prismaService.group.create({
data: { data: {
name, name,
code, slug,
}, },
}); });
} }
......
...@@ -10,7 +10,7 @@ export class Group { ...@@ -10,7 +10,7 @@ export class Group {
name: string; name: string;
@Field() @Field()
code: string; slug: string;
@Field(() => Int) @Field(() => Int)
tokens: number; tokens: number;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment