From accb147b54bc99e5cd20059be5cb333031f15885 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 18 Jul 2020 22:37:00 +0200 Subject: Added user registration Co-authored-by: LarsVomMars --- src/handler/user.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/handler') diff --git a/src/handler/user.ts b/src/handler/user.ts index fe65eaa..9881439 100644 --- a/src/handler/user.ts +++ b/src/handler/user.ts @@ -2,8 +2,16 @@ import type { HandlerFunc, Context } from "https://deno.land/x/abc@master/mod.ts import db from "../db/user.ts"; export const index: HandlerFunc = async (c: Context) => c.params.name; + export const register: HandlerFunc = async (c: Context) => { const { username, email, password } = await c.body(); - await db.createUser(email, username, password); + const success = await db.createUser(email, username, password); + // TODO: Send email + return { success }; +}; -} +export const login: HandlerFunc = async (c: Context) => { + const { username, password } = await c.body(); + const success = await db.login(username, password); + return { success }; +}; -- cgit v1.2.3