Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- actionSignin: async (req, res) => {
- try {
- const { username, password } = req.body;
- const user = await users.findOne({ username: username });
- if (!user) {
- req.flash("alertMessage", "User Not Found !");
- req.flash("alertStatus", "danger");
- res.redirect("/admin/signin");
- }
- const isPasswordMatch = await bycrypt.compare(password, user.password);
- if (!isPasswordMatch) {
- req.flash("alertMessage", "Password Not Match !");
- req.flash("alertStatus", "danger");
- res.redirect("/admin/signin");
- }
- req.session.user = {
- id: user.id,
- username: user.username,
- status : user.status
- }
- res.redirect('/admin/dashboard');
- } catch (error) {
- res.redirect("/admin/signin");
- }
- },
Add Comment
Please, Sign In to add comment