Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/ungdev/turboswitch
Browse files Browse the repository at this point in the history
  • Loading branch information
DevNono committed May 16, 2024
2 parents ef8d191 + 731336f commit 884218c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion web/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export async function generateCode() {
ciffers[Math.floor(Math.random() * 10)] +
ciffers[Math.floor(Math.random() * 10)] +
ciffers[Math.floor(Math.random() * 10)];
found = await prisma.opening.findFirst({ where: { code } });
found = await prisma.opening.findFirst({ where: { code, date: null } });
} while (found);
return code;
}
Expand Down
11 changes: 11 additions & 0 deletions web/src/webRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,17 @@ webRouter.get('/legal', async (request: Request, response: Response) => {
return response.sendFile(path.join(__dirname, "../www/legal.html"));
});

webRouter.get('/cancel', async (request: Request, response: Response) => {
if (!chestAlive()) return response.redirect('/down');
const login = authenticate(request);
if (!login) return response.redirect('/login');
const opening = await getWaitingOpening(login);
if (opening && opening.type === 'borrow') {
await prisma.opening.update({ where: { id: opening.id }, data: { code: null, codeGeneratedAt: null } });
}
return response.redirect('/');
});

webRouter.get('/', async (request: Request, response: Response) => {
if (!chestAlive()) return response.redirect('/down');
const login = authenticate(request);
Expand Down

0 comments on commit 884218c

Please sign in to comment.