fix type error in login.ts

This commit is contained in:
monoid 2021-10-11 22:52:03 +09:00
parent cd1d2c85d8
commit a96b740a15
1 changed files with 4 additions and 1 deletions

View File

@ -93,7 +93,7 @@ export const createLoginMiddleware = (userController: UserAccessor) =>
const secretKey = setting.jwt_secretkey;
const body = ctx.request.body;
//check format
if (!("username" in body) || !("password" in body)) {
if (typeof body == "string" || !("username" in body) || !("password" in body)) {
return sendError(
400,
"invalid form : username or password is not found in query.",
@ -249,6 +249,9 @@ export const resetPasswordMiddleware = (cntr: UserAccessor) =>
const username = body['username'];
const oldpw = body['oldpassword'];
const newpw = body['newpassword'];
if(typeof username !== "string" || typeof oldpw !== "string" || typeof newpw !== "string"){
return sendError(400,"request body is invalid format");
}
const user = await cntr.findUser(username);
if(user === undefined){
return sendError(403,"not authorized");