diff options
author | Marvin Borner | 2020-07-18 23:48:04 +0200 |
---|---|---|
committer | Marvin Borner | 2020-07-18 23:48:04 +0200 |
commit | 781f0baee0a6514fd57b4f964344febd32bc45d1 (patch) | |
tree | dbdd62e12c897f14fa6271a4f8fa3cd8763bdd8a /src/handler | |
parent | accb147b54bc99e5cd20059be5cb333031f15885 (diff) |
Fiiiiiixxxxx! (or sth)
Co-authored-by: LarsVomMars <lars@kroenner.eu>
Diffstat (limited to 'src/handler')
-rw-r--r-- | src/handler/user.ts | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/handler/user.ts b/src/handler/user.ts index 9881439..e194008 100644 --- a/src/handler/user.ts +++ b/src/handler/user.ts @@ -1,17 +1,25 @@ import type { HandlerFunc, Context } from "https://deno.land/x/abc@master/mod.ts"; -import db from "../db/user.ts"; +import db, {loginData} 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(); const success = await db.createUser(email, username, password); // TODO: Send email - return { success }; + return {success}; }; - export const login: HandlerFunc = async (c: Context) => { const { username, password } = await c.body(); - const success = await db.login(username, password); - return { success }; -}; + const data: loginData = await db.login(username, password); + if (data.success) { + c.setCookie({ + name: "uid", + value: data.uid!.toString(), + }); + c.setCookie({ + name: "verification", + value: data.verification!, + }) + } + return {"success": data.success}; +} |