better code

Massimo Melina committed Jun 21, 2022 at 11:55 UTC fa40f0814758d9f12e637b6f3dba88abafd6ae46
2 files changed +2 -5
frontend/src/useTheme.ts
-1
@@ -14,7 +14,6 @@ export default function useTheme() {
14 const pre = 'theme-'
15 const ct = pre + name
16 const list = e.classList
17 - console.debug({ theme, name, dark: systemDark })
17 for (const c of Array.from(list))
18 if (c.startsWith(pre) && c !== ct)
19 list.remove(c)
server/src/api.auth.ts
+2 -4
@@ -36,11 +36,9 @@ function makeExp() {
36 }
37
38 export const login: ApiHandler = async ({ username, password }, ctx) => {
39 - if (!username)
40 - return new ApiError(400)
41 - if (!password)
39 + if (!username || !password) // some validation
40 return new ApiError(400)
43 - username = username.toLocaleLowerCase()
41 + username = username.toLocaleLowerCase() // normalize username, to be case-insensitive
42 const acc = getAccount(username)
43 if (!acc)
44 return new ApiError(UNAUTHORIZED)