Skip to content

Commit

Permalink
Check username/password.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecao committed Oct 4, 2021
1 parent 20b8f59 commit 8bebbca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion pages/api/auth/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ import { serialize } from 'cookie';
import { checkPassword, createSecureToken } from 'lib/crypto';
import { getAccountByUsername } from 'lib/queries';
import { AUTH_COOKIE_NAME } from 'lib/constants';
import { ok, unauthorized } from 'lib/response';
import { ok, unauthorized, badRequest } from 'lib/response';

export default async (req, res) => {
const { username, password } = req.body;

if (!username || !password) {
return badRequest(res);
}

const account = await getAccountByUsername(username);

if (account && (await checkPassword(password, account.password))) {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1163,22 +1163,22 @@
minimatch "^3.0.4"
strip-json-comments "^3.1.1"

"@fontsource/inter@^4.5.0":
"@fontsource/[email protected]":
version "4.5.0"
resolved "https://registry.yarnpkg.com/@fontsource/inter/-/inter-4.5.0.tgz#b99e49fa178e4086250fb3df2ed6a7366c9a0cb5"
integrity sha512-2efK8Ru0LkuOYrEpiHPlV02YkTdIKGbezlxVNeA8/3c+tNt7P2aQPuiYYkVy7N4GA5LWSUVcLL/91MpCIjinOw==

"@fontsource/noto-sans-jp@^4.5.0":
"@fontsource/[email protected]":
version "4.5.0"
resolved "https://registry.yarnpkg.com/@fontsource/noto-sans-jp/-/noto-sans-jp-4.5.0.tgz#e9dbc9e3ccf37931da37cf932e6ceea7e1146499"
integrity sha512-BXe+enzyvI+iWYk7vr1cus0tc1wq8D7t08T1O5PuCZALJEYOPD3Knpl4ShVb6a9MXxaS25CjBhmc+r46uqyvpw==

"@fontsource/noto-sans-sc@^4.5.0":
"@fontsource/[email protected]":
version "4.5.0"
resolved "https://registry.yarnpkg.com/@fontsource/noto-sans-sc/-/noto-sans-sc-4.5.0.tgz#30d07b054788cc4a3f6a010cfdbd3726deeb8c37"
integrity sha512-pmK/cORHcu7oWLi6Waf6MXaAVyenfe8+mc5SqrA+mjZHPRsq/3j6C/hFFkCFG1wp5igFS8xd5Cz8L1elnSB/0A==

"@fontsource/noto-sans-tc@^4.5.0":
"@fontsource/[email protected]":
version "4.5.0"
resolved "https://registry.yarnpkg.com/@fontsource/noto-sans-tc/-/noto-sans-tc-4.5.0.tgz#ea83a2c0851241464a9aea5facd9be7455b0f2dd"
integrity sha512-7z8aT4aY5EJ8gggfJhUhtXL/CZQQSZ+HBuhXxiHy+NkvZG2Jz+Aa1kxrsJivzroJuK9dySYN4Pd/GENJv5WFqA==
Expand Down

0 comments on commit 8bebbca

Please sign in to comment.