Skip to content

Commit db92339

Browse files
committed
Implemented Login Functionality and completed the user dashboard page
1 parent d3ce8f7 commit db92339

File tree

6 files changed

+687
-7
lines changed

6 files changed

+687
-7
lines changed

controllers/user_controller.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
const sequelize = require('sequelize');
12
const User = require('../models/user');
3+
const path = require('path');
24

35
module.exports.signUp = async (req, res) => {
46
try {
@@ -24,4 +26,35 @@ module.exports.signUp = async (req, res) => {
2426
catch (error) {
2527
console.log(error);
2628
}
27-
};
29+
};
30+
31+
module.exports.signIn = async function (req, res) {
32+
try {
33+
const email = req.body.email;
34+
const password = req.body.password;
35+
36+
await User.findOne({ where: { email: email } }).then((user) => {
37+
if (!user) {
38+
res.status(404).send(`<script> window.location.href='/'; alert('User not found!'); </script>`);
39+
}
40+
41+
else if (user && user.password != password) {
42+
res.status(401).send(`<script> window.location.href='/'; alert('Password Incorrect!'); </script>`);
43+
}
44+
45+
else if (user && user.password == password) {
46+
res.status(200).send(`<script> window.location.href='/user_dashboard'; </script>`);
47+
48+
}
49+
}).catch((err) => {
50+
console.log(err);
51+
});
52+
}
53+
catch (err) {
54+
console.log(err);
55+
}
56+
}
57+
58+
module.exports.userDashboard = function (req, res) {
59+
res.sendFile(path.join(__dirname, '../public/views/user_dashboard.html'));
60+
}

public/css/user_dashboard.css

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
html,body {
2+
height: 100%;
3+
width: 100%;
4+
background-color: #effeff;
5+
}
6+
7+
.editDelete {
8+
float: right;
9+
margin: 3px;
10+
padding: 3px 10px;
11+
}
12+
#png {
13+
margin-right: 10px;
14+
}
15+
#form1 {
16+
border-radius: 10px;
17+
background-color: #3d5a80;
18+
box-shadow: 4px 4px 9px #293241;
19+
margin: 20px 193px;
20+
}
21+
#table {
22+
border-radius: 10px;
23+
background-color: #d2eaf7;
24+
/* background-image: linear-gradient(to bottom right, #c7e9fd, #3d5a80); */
25+
box-shadow: 4px 4px 9px #b8b8b8;
26+
}
27+
#submitBtn {
28+
width: 140px;
29+
background-color: #293241;
30+
border-color: #293241;
31+
color: white;
32+
}
33+
.topBtn {
34+
background-color: white;
35+
border-color: white;
36+
color: #293241;
37+
}
38+
#navigation {
39+
background-color: #233b64;
40+
}
41+
#categoryBtn {
42+
background-color: #293241;
43+
width: auto;
44+
border-radius: 7px;
45+
border: none;
46+
color: white;
47+
}
48+
#category {
49+
width: 300px;
50+
}
51+
.input-group-text {
52+
background-color: #293241;
53+
color: white;
54+
border: none;
55+
}
56+
#description {
57+
width: 2000px;
58+
}
59+
60+
.trStyle {
61+
background-color: transparent;
62+
}
63+
#categoryBtn:hover,#submitBtn:hover,.editDelete:hover {
64+
background-color: #ffffff;
65+
color: #293241;
66+
border-color: #293241;
67+
}
68+
.topBtn:hover {
69+
background-color: #3d5a80;
70+
color: white;
71+
border-color: #3d5a80;
72+
}
73+
.editDelete {
74+
background-color: #293241;
75+
border: none;
76+
}
77+
78+
#tableHead {
79+
background-color: #3d5a80;
80+
color: white;
81+
}
82+
.page-link {
83+
background-color: #3d5a80;
84+
color: white;
85+
}
86+
.page-link:hover {
87+
background-color: #d2eaf7;
88+
color: #233b64;
89+
}

0 commit comments

Comments
 (0)