Handle website delete. Added response helper functions.

This commit is contained in:
Mike Cao 2020-08-07 17:19:42 -07:00
parent 0a411a9ad6
commit c4b75e4aec
31 changed files with 314 additions and 96 deletions

View file

@ -2,6 +2,7 @@ import { serialize } from 'cookie';
import { checkPassword, createSecureToken } from 'lib/crypto';
import { getAccount } from 'lib/db';
import { AUTH_COOKIE_NAME } from 'lib/constants';
import { ok, unauthorized } from 'lib/response';
export default async (req, res) => {
const { username, password } = req.body;
@ -19,8 +20,8 @@ export default async (req, res) => {
res.setHeader('Set-Cookie', [cookie]);
return res.status(200).json({ token });
return ok(res, { token });
}
return res.status(401).end();
return unauthorized(res);
};