This commit is contained in:
lingdocs 2021-08-22 12:19:03 +04:00
parent 2e7defbf61
commit 3fea41977f
1 changed files with 31 additions and 27 deletions

View File

@ -91,8 +91,9 @@ apiRouter.put("/email-verification", async (req, res, next) => {
}
});
apiRouter.post("/user/upgrade", async (req, res, next) => {
apiRouter.put("/user/upgrade", async (req, res, next) => {
if (!req.user) throw new Error("user not found");
try {
const givenPassword = (req.body.password || "") as string;
const studentPassword = env.upgradePassword;
if (givenPassword.toLowerCase().trim() !== studentPassword.toLowerCase()) {
@ -122,6 +123,9 @@ apiRouter.post("/user/upgrade", async (req, res, next) => {
user: u,
};
res.send(upgraded);
} catch (e) {
next(e);
}
});
/**