Skip to content

Commit

Permalink
Bootstrap version bumped to 5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
mangya committed Dec 11, 2024
1 parent d00331e commit c70bd31
Show file tree
Hide file tree
Showing 27 changed files with 394 additions and 446 deletions.
14 changes: 7 additions & 7 deletions app/controllers/AuthController.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ const oldInput = (req) => {
return oldInput;
}

exports.loginPage = (req, res, next) => {
exports.loginPage = (req, res) => {
if(res.locals.isAuthenticated){
res.redirect('/');
} else {
res.render('login',{layout: 'login_layout', loginPage: true, pageTitle: 'Login', errorMessage: message(req), oldInput: oldInput(req)});
}
};

exports.login = (req, res, next) => {
exports.login = (req, res) => {
const validationErrors = [];
if (!validator.isEmail(req.body.inputEmail)) validationErrors.push('Please enter a valid email address.');
if (validator.isEmpty(req.body.inputPassword)) validationErrors.push('Password cannot be blank.');
Expand Down Expand Up @@ -78,7 +78,7 @@ exports.login = (req, res, next) => {
.catch(err => console.log(err));
};

exports.logout = (req, res, next) => {
exports.logout = (req, res) => {
if(res.locals.isAuthenticated){
req.session.destroy(err => {
return res.redirect('/');
Expand All @@ -88,11 +88,11 @@ exports.logout = (req, res, next) => {
}
};

exports.signUpPage = (req, res, next) => {
exports.signUpPage = (req, res) => {
res.render('sign_up',{layout: 'login_layout', signUpPage: true, errorMessage: message(req), oldInput: oldInput(req)});
};

exports.signUp = (req, res, next) => {
exports.signUp = (req, res) => {
User.findOne({
where: {
email: req.body.email
Expand Down Expand Up @@ -121,15 +121,15 @@ exports.signUp = (req, res, next) => {
.catch(err => console.log(err));
};

exports.forgotPasswordPage = (req, res, next) => {
exports.forgotPasswordPage = (req, res) => {
if(res.locals.isAuthenticated){
return res.redirect('/');
} else {
return res.render('forgot_password',{layout: 'login_layout', loginPage: true, pageTitle: 'Forgot Password', errorMessage: message(req), oldInput: oldInput(req)});
}
};

exports.forgotPassword = (req, res, next) => {
exports.forgotPassword = (req, res) => {
const validationErrors = [];
if (!validator.isEmail(req.body.email)) validationErrors.push('Please enter a valid email address.');

Expand Down
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ app.use(session({
resave: true,
saveUninitialized: true,
secret: process.env.SESSION_SECRET,
cookie: { maxAge: 1209600000 }, // two weeks in milliseconds
cookie: { path: '/', httpOnly: true, maxAge: 1209600000 }, // maxAge two weeks in milliseconds, remove secure: true for local development
store: new SequelizeStore({
db: sequelize,
table: "sessions",
Expand All @@ -48,6 +48,9 @@ app.engine(
expressHbs.engine({
layoutsDir: 'views/layouts/',
defaultLayout: 'web_layout',
partialsDir: [
"views/partials/",
],
extname: 'hbs'
})
);
Expand Down
Loading

0 comments on commit c70bd31

Please sign in to comment.