Skip to content

Commit

Permalink
added a demo-sign in feature to main page
Browse files Browse the repository at this point in the history
  • Loading branch information
flbarfield committed Feb 21, 2024
1 parent 1fdca2a commit 284a1dc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 42 deletions.
43 changes: 1 addition & 42 deletions controllers/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,45 +109,4 @@ const User = require('../models/user')
} catch (err) {
return next(err);
}
};

// Dated code - no longer works for postSignUp

// exports.postSignup = (req, res, next) => {
// const validationErrors = []
// if (!validator.isEmail(req.body.email)) validationErrors.push({ msg: 'Please enter a valid email address.' })
// if (!validator.isLength(req.body.password, { min: 8 })) validationErrors.push({ msg: 'Password must be at least 8 characters long' })
// if (req.body.password !== req.body.confirmPassword) validationErrors.push({ msg: 'Passwords do not match' })

// if (validationErrors.length) {
// req.flash('errors', validationErrors)
// return res.redirect('/')
// }
// req.body.email = validator.normalizeEmail(req.body.email, { gmail_remove_dots: false })

// const user = new User({
// userName: req.body.userName,
// email: req.body.email,
// password: req.body.password
// })

// User.findOne({$or: [
// {email: req.body.email},
// {userName: req.body.userName}
// ]}, (err, existingUser) => {
// if (err) { return next(err) }
// if (existingUser) {
// req.flash('errors', { msg: 'Account with that email address or username already exists.' })
// return res.redirect('../signup')
// }
// user.save((err) => {
// if (err) { return next(err) }
// req.logIn(user, (err) => {
// if (err) {
// return next(err)
// }
// res.redirect('/fitnessApp')
// })
// })
// })
// }
};
14 changes: 14 additions & 0 deletions node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@
<ul class="actions">
<li><a href="#signIn" class="button">Sign In</a></li>
<li><a href="#register" class="button">Register</a></li>
<li>
<form action="/login" method="post">
<input name="email" type="hidden" value="[email protected]">
<input name="userName" type="hidden" value="guest">
<input name="password" type="hidden" value="password12345">
<input href="#signIn" value='Demo Sign In' type="submit" class="button"/>
</form>

</li>

</ul>
</div>
<span class="image"><img src="/images/aerialistAtWork.jpg" alt="" /></span>
Expand Down

0 comments on commit 284a1dc

Please sign in to comment.