diff --git a/pages/api/auth/login.js b/pages/api/auth/login.js index 6ab826df..be2400a0 100644 --- a/pages/api/auth/login.js +++ b/pages/api/auth/login.js @@ -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))) { diff --git a/yarn.lock b/yarn.lock index 8393578e..830093b0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1163,22 +1163,22 @@ minimatch "^3.0.4" strip-json-comments "^3.1.1" -"@fontsource/inter@^4.5.0": +"@fontsource/inter@4.5.0": 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/noto-sans-jp@4.5.0": 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/noto-sans-sc@4.5.0": 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/noto-sans-tc@4.5.0": 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==