Components for user modification, email validation
This commit is contained in:
parent
01227bb28f
commit
99a3d7ff33
9 changed files with 193 additions and 3 deletions
23
backend/src/app/controllers/user/validate.ts
Normal file
23
backend/src/app/controllers/user/validate.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { Request, Response } from "express";
|
||||
import Users from "../../models/User";
|
||||
import { LOGGER } from "../../util/Logger";
|
||||
|
||||
export default async (req: Request, res: Response) => {
|
||||
try {
|
||||
const user = await Users.findById(req.query._id);
|
||||
if (!user) {
|
||||
return res.status(404).send("User not found");
|
||||
}
|
||||
|
||||
user.isEmailValidated = true;
|
||||
await user.save();
|
||||
return res
|
||||
.status(200)
|
||||
.send(
|
||||
"Thank you for validating your email address! You may now close this window."
|
||||
);
|
||||
} catch (ex) {
|
||||
LOGGER.error(ex);
|
||||
return res.status(500).send("Uh oh! Something went wrong..");
|
||||
}
|
||||
};
|
||||
Loading…
Reference in a new issue