Check username

This commit is contained in:
RealMANI 2022-03-06 12:37:16 +03:30 committed by Erkin Alp Güney
parent b51e687793
commit fa750de6fb

View File

@ -57,12 +57,14 @@ router.patch("/", route({ body: "UserModifySchema" }), async (req: Request, res:
user.data.hash = await bcrypt.hash(body.new_password, 12); user.data.hash = await bcrypt.hash(body.new_password, 12);
} }
var check_username = body?.username?.replace(/\s/g, ''); if(body.username){
if(!check_username && !body?.avatar && !body?.banner && !body?.bio && !body?.accent_color) { var check_username = body?.username?.replace(/\s/g, '');
throw FieldErrors({ if(!check_username) {
username: { code: "BASE_TYPE_REQUIRED", message: req.t("common:field.BASE_TYPE_REQUIRED") } throw FieldErrors({
}); username: { code: "BASE_TYPE_REQUIRED", message: req.t("common:field.BASE_TYPE_REQUIRED") }
} });
}
}
await user.save(); await user.save();