Don't fail if row is undefined

This commit is contained in:
Ajay Ramachandran
2021-06-30 00:01:40 -04:00
parent 4d8526c24d
commit ce59d3f95f
2 changed files with 17 additions and 1 deletions

View File

@@ -66,7 +66,7 @@ export async function setUsername(req: Request, res: Response) {
const locked = adminUserIDInput === undefined ? 0 : 1;
let oldUserName = '';
if (row.userName && row.userName.length !== 0) {
if (row?.userName?.length > 0) {
//already exists, update this row
oldUserName = row.userName;
await db.prepare('run', `UPDATE "userNames" SET "userName" = ?, "locked" = ? WHERE "userID" = ?`, [userName, locked, userID]);