├── .DS_Store
├── .gitignore
├── 12-Rules-to-Learn-to-Code-eBook-Updated-26.11.18.pdf
├── DOM
├── css
│ └── master.css
├── index.html
└── javascript
│ └── main.js
├── Dicee Challenge
├── .DS_Store
├── dicee.html
├── images
│ ├── dice1.png
│ ├── dice2.png
│ ├── dice3.png
│ ├── dice4.png
│ ├── dice5.png
│ └── dice6.png
├── index.js
└── styles.css
├── Drum Kit
├── .DS_Store
├── images
│ ├── crash.png
│ ├── kick.png
│ ├── snare.png
│ ├── tom1.png
│ ├── tom2.png
│ ├── tom3.png
│ └── tom4.png
├── index.html
├── index.js
├── sounds
│ ├── crash.mp3
│ ├── kick-bass.mp3
│ ├── snare.mp3
│ ├── tom-1.mp3
│ ├── tom-2.mp3
│ ├── tom-3.mp3
│ └── tom-4.mp3
└── styles.css
├── README.md
├── Secrets - Starting Code
├── .DS_Store
├── app.js
├── package-lock.json
├── package.json
├── public
│ └── css
│ │ └── styles.css
└── views
│ ├── home.ejs
│ ├── login.ejs
│ ├── partials
│ ├── footer.ejs
│ └── header.ejs
│ ├── register.ejs
│ ├── secrets.ejs
│ └── submit.ejs
├── Simon Game Challenge Starting Files
├── .DS_Store
├── game.js
├── index.html
├── sounds
│ ├── blue.mp3
│ ├── green.mp3
│ ├── red.mp3
│ ├── wrong.mp3
│ └── yellow.mp3
└── styles.css
├── TinDog-Start-master.zip
├── TinDog-Start-master
├── .DS_Store
├── README.md
├── css
│ ├── .DS_Store
│ └── styles.css
├── images
│ └── .DS_Store
└── index.html
├── bitcoin-ticker
├── index.html
├── index.js
├── package-lock.json
└── package.json
├── bootstrap
├── css
│ └── master.css
├── images
│ ├── TechCrunch.png
│ ├── bizinsider.png
│ ├── dog-img.jpg
│ ├── iphone6.png
│ ├── lady-img.jpg
│ ├── mashable.png
│ └── tnw.png
└── index.html
├── boss-level-challenge
├── app.js
├── package-lock.json
├── package.json
├── public
│ ├── .DS_Store
│ ├── css
│ │ └── styles.css
│ └── javascript
│ │ └── main.js
└── views
│ ├── .DS_Store
│ ├── about.ejs
│ ├── compose.ejs
│ ├── contact.ejs
│ ├── home.ejs
│ ├── partials
│ ├── footer.ejs
│ └── header.ejs
│ └── post.ejs
├── calculator
├── bmiCalculator.html
├── calculator.js
├── index.html
├── package-lock.json
└── package.json
├── favicon_io
├── .DS_Store
├── android-chrome-192x192.png
├── android-chrome-512x512.png
├── apple-touch-icon.png
├── cloud (1).png
├── cloudy (1).png
├── css.png
├── favicon-16x16.png
├── favicon-32x32.png
├── github.png
├── html-5.png
├── html.png
├── java.png
├── lake.png
├── logo-via-logohub.png
├── mountain (1).png
├── mountains.png
├── web.png
└── www-click.png
├── html-personal-site
├── .DS_Store
├── contact.html
├── css
│ └── style.css
├── hobbies.html
├── images
│ ├── .DS_Store
│ └── sabrina-picture.jpg
└── index.html
├── index.js
├── into-to-node
├── index.js
├── package-lock.json
└── package.json
├── jquery
├── index.html
├── main.js
└── style.css
├── learn
└── learn.html
├── my-express-server
├── package-lock.json
├── package.json
└── server.js
├── newsletter-signup
├── app.js
├── failure.html
├── package-lock.json
├── package.json
├── public
│ ├── css
│ │ └── style.css
│ └── images
│ │ └── application.png
├── signup.html
└── success.html
├── personalwebsite
├── .DS_Store
├── CSS_My_Site_End_Results.pdf
├── css
│ └── master.css
├── home.html
└── images
│ ├── .DS_Store
│ ├── cloud-with-sun.png
│ ├── cloud.png
│ ├── code.png
│ ├── favicon.ico
│ ├── interview.png
│ ├── javascript.png
│ ├── mountain.png
│ ├── sabrina-picture.jpg
│ └── test.png
└── todolist-v1
├── app.js
├── date.js
├── index.html
├── package-lock.json
├── package.json
├── public
└── css
│ └── styles.css
└── views
├── about.ejs
├── footer.ejs
├── header.ejs
└── list.ejs
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/.DS_Store
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Logs
3 | logs
4 | *.log
5 | npm-debug.log*
6 | yarn-debug.log*
7 | yarn-error.log*
8 | lerna-debug.log*s
9 |
10 | # Diagnostic reports (https://nodejs.org/api/report.html)
11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12 |
13 | # Runtime data
14 | pids
15 | *.pid
16 | *.seed
17 | *.pid.lock
18 |
19 | # Directory for instrumented libs generated by jscoverage/JSCover
20 | lib-cov
21 |
22 | # Coverage directory used by tools like istanbul
23 | coverage
24 | *.lcov
25 |
26 | # nyc test coverage
27 | .nyc_output
28 |
29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
30 | .grunt
31 |
32 | # Bower dependency directory (https://bower.io/)
33 | bower_components
34 |
35 | # node-waf configuration
36 | .lock-wscript
37 |
38 | # Compiled binary addons (https://nodejs.org/api/addons.html)
39 | build/Release
40 |
41 | # Dependency directories
42 | node_modules/
43 | jspm_packages/
44 |
45 | # TypeScript v1 declaration files
46 | typings/
47 |
48 | # TypeScript cache
49 | *.tsbuildinfo
50 |
51 | # Optional npm cache directory
52 | .npm
53 |
54 | # Optional eslint cache
55 | .eslintcache
56 |
57 | # Optional REPL history
58 | .node_repl_history
59 |
60 | # Output of 'npm pack'
61 | *.tgz
62 |
63 | # Yarn Integrity file
64 | .yarn-integrity
65 |
66 | # dotenv environment variables file
67 | .env
68 | .env.test
69 |
70 | # parcel-bundler cache (https://parceljs.org/)
71 | .cache
72 |
73 | # next.js build output
74 | .next
75 |
76 | # nuxt.js build output
77 | .nuxt
78 |
79 | # vuepress build output
80 | .vuepress/dist
81 |
82 | # Serverless directories
83 | .serverless/
84 |
85 | # FuseBox cache
86 | .fusebox/
87 |
88 | # DynamoDB Local files
89 | .dynamodb/
90 |
--------------------------------------------------------------------------------
/12-Rules-to-Learn-to-Code-eBook-Updated-26.11.18.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/12-Rules-to-Learn-to-Code-eBook-Updated-26.11.18.pdf
--------------------------------------------------------------------------------
/DOM/css/master.css:
--------------------------------------------------------------------------------
1 | h1{
2 | color: blue;
3 | }
4 |
--------------------------------------------------------------------------------
/DOM/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | DOM
6 |
7 |
8 |
9 | Hello
10 |
11 |
12 |
13 |
14 |
15 |
16 | -
17 | Google
18 |
19 | - Second
20 | - Thrid
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/DOM/javascript/main.js:
--------------------------------------------------------------------------------
1 | alert('Hello you')
2 |
--------------------------------------------------------------------------------
/Dicee Challenge/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Dicee Challenge/.DS_Store
--------------------------------------------------------------------------------
/Dicee Challenge/dicee.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Dicee
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Refresh Me
14 |
15 |
16 |
Player 1
17 |

18 |
19 |
20 |
21 |
Player 2
22 |

23 |
24 |
25 |
26 |
27 |
28 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/Dicee Challenge/images/dice1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Dicee Challenge/images/dice1.png
--------------------------------------------------------------------------------
/Dicee Challenge/images/dice2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Dicee Challenge/images/dice2.png
--------------------------------------------------------------------------------
/Dicee Challenge/images/dice3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Dicee Challenge/images/dice3.png
--------------------------------------------------------------------------------
/Dicee Challenge/images/dice4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Dicee Challenge/images/dice4.png
--------------------------------------------------------------------------------
/Dicee Challenge/images/dice5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Dicee Challenge/images/dice5.png
--------------------------------------------------------------------------------
/Dicee Challenge/images/dice6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Dicee Challenge/images/dice6.png
--------------------------------------------------------------------------------
/Dicee Challenge/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Start the game
3 | */
4 | function startGame(){
5 |
6 | var diceOne = random(6, 1);
7 | var diceTwo = random(6, 1);
8 |
9 | changeImage('img1', diceOne);
10 | changeImage('img2', diceTwo);
11 |
12 | if(diceOne > diceTwo){
13 | document.getElementById('title').innerHTML = 'Player 1 Wins! 🏆'
14 | }else if (diceTwo > diceOne){
15 | document.getElementById('title').innerHTML = 'Player 2 Wins! 🏆'
16 | }else{
17 | document.getElementById('title').innerHTML = 'Draw!'
18 | }
19 |
20 | }
21 |
22 | /*
23 | * Random number
24 | */
25 | function random (max, min){
26 |
27 | //return parseInt(Math.random() * (max - min) + min);
28 | return Math.floor(Math.random() * 6) + 1;
29 |
30 | }
31 |
32 | /*
33 | * Change the image
34 | */
35 | function changeImage(img, number){
36 |
37 | switch (number) {
38 | case 1:
39 | document.getElementById(img).src = 'images/dice1.png'
40 | break;
41 | case 2:
42 | document.getElementById(img).src = 'images/dice2.png'
43 | break;
44 | case 3:
45 | document.getElementById(img).src = 'images/dice3.png'
46 | break;
47 | case 4:
48 | document.getElementById(img).src = 'images/dice4.png'
49 | break;
50 | case 5:
51 | document.getElementById(img).src = 'images/dice5.png'
52 | break;
53 | default:
54 | document.getElementById(img).src = 'images/dice5.png'
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/Dicee Challenge/styles.css:
--------------------------------------------------------------------------------
1 | .container {
2 | width: 70%;
3 | margin: auto;
4 | text-align: center;
5 | }
6 |
7 | .dice {
8 | text-align: center;
9 | display: inline-block;
10 |
11 | }
12 |
13 | body {
14 | background-color: #393E46;
15 | }
16 |
17 | h1 {
18 | margin: 30px;
19 | font-family: 'Lobster', cursive;
20 | text-shadow: 5px 0 #232931;
21 | font-size: 8rem;
22 | color: #4ECCA3;
23 | }
24 |
25 | p {
26 | font-size: 2rem;
27 | color: #4ECCA3;
28 | font-family: 'Indie Flower', cursive;
29 | }
30 |
31 | img {
32 | width: 80%;
33 | }
34 |
35 | footer {
36 | margin-top: 5%;
37 | color: #EEEEEE;
38 | text-align: center;
39 | font-family: 'Indie Flower', cursive;
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/Drum Kit/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Drum Kit/.DS_Store
--------------------------------------------------------------------------------
/Drum Kit/images/crash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Drum Kit/images/crash.png
--------------------------------------------------------------------------------
/Drum Kit/images/kick.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Drum Kit/images/kick.png
--------------------------------------------------------------------------------
/Drum Kit/images/snare.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Drum Kit/images/snare.png
--------------------------------------------------------------------------------
/Drum Kit/images/tom1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Drum Kit/images/tom1.png
--------------------------------------------------------------------------------
/Drum Kit/images/tom2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Drum Kit/images/tom2.png
--------------------------------------------------------------------------------
/Drum Kit/images/tom3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Drum Kit/images/tom3.png
--------------------------------------------------------------------------------
/Drum Kit/images/tom4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Drum Kit/images/tom4.png
--------------------------------------------------------------------------------
/Drum Kit/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Drum Kit
7 |
8 |
9 |
10 |
11 |
12 |
13 | Drum 🥁 Kit
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Drum Kit/index.js:
--------------------------------------------------------------------------------
1 | document.addEventListener('keydown', function(event){
2 |
3 | handleSounds(event.key);
4 |
5 | });
6 |
7 |
8 | function play(element){
9 |
10 | handleSounds(element.id);
11 |
12 | }
13 |
14 | function handleSounds(position){
15 |
16 | switch (position) {
17 | case 'first', 'w':
18 |
19 | var firstAudio = new Audio('sounds/tom-1.mp3')
20 | firstAudio.play()
21 |
22 | break;
23 | case 'second', 'a':
24 |
25 | var secondAudio = new Audio('sounds/tom-2.mp3')
26 | secondAudio.play()
27 |
28 | break;
29 | case 'third', 's':
30 |
31 | var thirdAudio = new Audio('sounds/tom-3.mp3')
32 | thirdAudio.play()
33 |
34 | break;
35 | case 'fourth', 'd':
36 |
37 | var fourthAudio = new Audio('sounds/tom-4.mp3')
38 | fourthAudio.play()
39 |
40 | break;
41 | case 'fiveth', 'j':
42 |
43 | var fivethAudio = new Audio('sounds/crash.mp3')
44 | fivethAudio.play()
45 |
46 | break;
47 | case 'sixth', 'k':
48 |
49 | var sixthAudio = new Audio('sounds/kick-bass.mp3')
50 | sixthAudio.play()
51 |
52 | break;
53 | case 'seventh', 'l':
54 |
55 | var seventhAudio = new Audio('sounds/snare.mp3')
56 | seventhAudio.play()
57 |
58 | break;
59 | default:
60 | //console.log('nothing will happen');
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Drum Kit/sounds/crash.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Drum Kit/sounds/crash.mp3
--------------------------------------------------------------------------------
/Drum Kit/sounds/kick-bass.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Drum Kit/sounds/kick-bass.mp3
--------------------------------------------------------------------------------
/Drum Kit/sounds/snare.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Drum Kit/sounds/snare.mp3
--------------------------------------------------------------------------------
/Drum Kit/sounds/tom-1.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Drum Kit/sounds/tom-1.mp3
--------------------------------------------------------------------------------
/Drum Kit/sounds/tom-2.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Drum Kit/sounds/tom-2.mp3
--------------------------------------------------------------------------------
/Drum Kit/sounds/tom-3.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Drum Kit/sounds/tom-3.mp3
--------------------------------------------------------------------------------
/Drum Kit/sounds/tom-4.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Drum Kit/sounds/tom-4.mp3
--------------------------------------------------------------------------------
/Drum Kit/styles.css:
--------------------------------------------------------------------------------
1 | body {
2 | text-align: center;
3 | background-color: #283149;
4 | }
5 |
6 | h1 {
7 | font-size: 5rem;
8 | color: #DBEDF3;
9 | font-family: "Arvo", cursive;
10 | text-shadow: 3px 0 #DA0463;
11 |
12 | }
13 |
14 | footer {
15 | color: #DBEDF3;
16 | font-family: sans-serif;
17 | }
18 |
19 | .w {
20 | background-image: url('images/tom1.png');
21 | }
22 |
23 | .a {
24 | background-image: url('images/tom2.png');
25 | }
26 |
27 | .s {
28 | background-image: url('images/tom3.png');
29 | }
30 |
31 | .d {
32 | background-image: url('images/tom4.png');
33 | }
34 |
35 | .j {
36 | background-image: url('images/crash.png');
37 | }
38 |
39 | .k {
40 | background-image: url('images/kick.png');
41 | }
42 |
43 | .l {
44 | background-image: url('images/snare.png');
45 | }
46 |
47 | .set {
48 | margin: 10% auto;
49 | }
50 |
51 | .game-over {
52 | background-color: red;
53 | opacity: 0.8;
54 | }
55 |
56 | .pressed {
57 | box-shadow: 0 3px 4px 0 #DBEDF3;
58 | opacity: 0.5;
59 | }
60 |
61 | .red {
62 | color: red;
63 | }
64 |
65 | .drum {
66 | outline: none;
67 | border: 10px solid #404B69;
68 | font-size: 5rem;
69 | font-family: 'Arvo', cursive;
70 | line-height: 2;
71 | font-weight: 900;
72 | color: #DA0463;
73 | text-shadow: 3px 0 #DBEDF3;
74 | border-radius: 15px;
75 | display: inline-block;
76 | width: 150px;
77 | height: 150px;
78 | text-align: center;
79 | margin: 10px;
80 | background-color: white;
81 | }
82 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # The Complete 2020 Web Development Bootcamp
3 |
4 | Whats I will learn:
5 |
6 | - Be able to build ANY website you want.
7 |
8 | - Craft a portfolio of websites to apply for junior developer jobs.
9 |
10 | - Build fully-fledged websites and web apps for your startup or business.
11 |
12 | - Work as a freelance web developer.
13 |
14 | - Master backend development with Node
15 |
16 | - Master frontend development with React
17 |
18 | - Learn the latest frameworks and technologies, including Javascript ES6, Bootstrap 4, MongoDB.
19 |
20 | - Learn professional developer best practices.
21 |
22 | link: https://www.udemy.com/course/the-complete-web-development-bootcamp/
23 |
--------------------------------------------------------------------------------
/Secrets - Starting Code/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/angelabauer/web-development-bootcamp/17bc36d8234ef10f70f66c401fb0838b3e48e823/Secrets - Starting Code/.DS_Store
--------------------------------------------------------------------------------
/Secrets - Starting Code/app.js:
--------------------------------------------------------------------------------
1 | require("dotenv").config();
2 |
3 | const express = require("express");
4 | const bodyparser = require("body-parser");
5 | const ejs = require("ejs");
6 | const mongoose = require("mongoose");
7 |
8 | //const encryption = require("mongoose-encryption");
9 | //const md5 = require("md5");
10 | //const bcrypt = require("bcrypt");
11 |
12 | const session = require("express-session");
13 | const passport = require("passport");
14 | const passportLocalMongoose = require("passport-local-mongoose");
15 |
16 |
17 | const salt = 10;
18 | const app = express();
19 |
20 | app.use(express.static("public"));
21 | app.set("view engine", "ejs");
22 | app.use(bodyparser.urlencoded({ extended: true}));
23 |
24 | app.use(session({
25 | secret: "our litter secret",
26 | resave: false,
27 | saveUninitialized: false
28 | }));
29 |
30 | app.use(passport.initialize());
31 | app.use(passport.session());
32 |
33 |
34 | mongoose.connect("mongodb://localhost:27017/userDB", { useNewUrlParser: true, useUnifiedTopology: true });
35 | mongoose.set("useCreateIndex", true);
36 |
37 |
38 | const userSchema = new mongoose.Schema({
39 | email: String,
40 | password: String,
41 | secret: String
42 | });
43 |
44 |
45 | //const secret = "thisisourlittesecret";
46 | //userSchema.plugin(encryption, { secret: process.env.SECRET, encryptedFields: ["password"]});
47 |
48 | userSchema.plugin(passportLocalMongoose);
49 |
50 | const User = mongoose.model("User", userSchema)
51 |
52 |
53 | passport.use(User.createStrategy());
54 |
55 | passport.serializeUser(User.serializeUser());
56 | passport.deserializeUser(User.deserializeUser());
57 |
58 |
59 | // home
60 | app.get("/", function(req, res) {
61 |
62 | res.render("home");
63 | });
64 |
65 | // secrets
66 | app.get("/secrets", function(req, res){
67 |
68 | if(req.isAuthenticated()){
69 | User.find({ "secret": {$ne:null} }, function(err, users){
70 | if(err){
71 | console.log(err);
72 | }else{
73 | if(users){
74 | res.render("secrets", { users: users});
75 | }
76 | }
77 | });
78 |
79 | }else{
80 | res.redirect("/login");
81 | }
82 | });
83 |
84 |
85 | // login
86 | app.get("/login", function(req, res) {
87 |
88 | res.render("login");
89 | });
90 |
91 | app.post("/login", function(req, res){
92 |
93 | const user = new User({
94 | username: req.body.username,
95 | password: req.body.password
96 | });
97 |
98 | req.login(user, function(err){
99 | if(err){
100 | console.log(err);
101 | }else{
102 | passport.authenticate("local")(req, res, function(){
103 | res.redirect("/secrets");
104 | });
105 | }
106 | });
107 | });
108 |
109 | app.get("/logout", function(req, res){
110 |
111 | req.logout();
112 | res.redirect("/");
113 | });
114 |
115 | /*
116 | app.post("/login", function(req, res) {
117 |
118 | const username = req.body.username;
119 | const password = req.body.password;
120 |
121 | User.findOne({ email: username}, function(error, user){
122 | if(error){
123 | console.log(error);
124 | }else{
125 | if(user){
126 |
127 | bcrypt.compare(password, user.password, function(err, result) {
128 | if(result === true){
129 | res.render("secrets");
130 | }
131 | });
132 |
133 | }
134 | }
135 | })
136 |
137 | });
138 | */
139 |
140 |
141 | // register
142 | app.get("/register", function(req, res) {
143 |
144 | res.render("register");
145 | });
146 |
147 | app.post("/register", function(req, res){
148 |
149 | User.register({username: req.body.username, active: false}, req.body.password, function(err, user){
150 | if(err){
151 | console.log(err);
152 | res.redirect("/register")
153 | }else{
154 | passport.authenticate("local")(req, res, function(){
155 | res.redirect("/secrets");
156 | });
157 | }
158 |
159 |
160 | });
161 | });
162 |
163 | /*
164 | app.post("/register", function(req, res) {
165 |
166 | bcrypt.hash(req.body.password, salt, function(err, hash) {
167 | const newUser = new User({
168 | email: req.body.username,
169 | password: hash
170 | });
171 |
172 | newUser.save(function(error){
173 | if(error){
174 | console.log(error);
175 | }else{
176 | res.render("secrets");
177 | }
178 | });
179 | });
180 | });
181 | */
182 |
183 |
184 | app.get("/submit", function(req, res){
185 |
186 | if(req.isAuthenticated()){
187 | res.render("submit");
188 | }else{
189 | res.redirect("/login");
190 | }
191 | })
192 |
193 | app.post("/submit", function(req, res){
194 |
195 | const submittedSecret = req.body.secret;
196 |
197 | console.log(req.user); // passport
198 |
199 | User.findById(req.user.id, function(err, user){
200 | if(err){
201 | console.log(err);
202 | }else{
203 | if(user){
204 | user.secret = submittedSecret;
205 | user.save(function(){
206 | res.redirect("/secrets");
207 | });
208 | }
209 | }
210 | })
211 |
212 | });
213 |
214 |
215 | app.listen("3000", function(){
216 | console.log("server running at port 3000");
217 | })
218 |
--------------------------------------------------------------------------------
/Secrets - Starting Code/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "secrets",
3 | "version": "1.0.0",
4 | "main": "app.js",
5 | "scripts": {
6 | "test": "echo \"Error: no test specified\" && exit 1"
7 | },
8 | "author": "",
9 | "license": "ISC",
10 | "dependencies": {
11 | "bcrypt": "^3.0.6",
12 | "body-parser": "^1.19.0",
13 | "dotenv": "^8.1.0",
14 | "ejs": "^2.6.2",
15 | "express": "^4.17.1",
16 | "express-session": "^1.16.2",
17 | "md5": "^2.2.1",
18 | "mongoose": "^5.7.1",
19 | "mongoose-encryption": "^2.0.2",
20 | "nodemon": "^1.19.1",
21 | "passport": "^0.4.0",
22 | "passport-local": "^1.0.0",
23 | "passport-local-mongoose": "^5.0.1"
24 | },
25 | "description": ""
26 | }
27 |
--------------------------------------------------------------------------------
/Secrets - Starting Code/public/css/styles.css:
--------------------------------------------------------------------------------
1 |
2 | body {
3 | background-color: #E8ECEF;
4 | }
5 |
6 | .centered {
7 | padding-top: 200px;
8 | text-align: center;
9 | }
10 |
11 | .secret-text {
12 | text-align: center;
13 | font-size: 2rem;
14 | color: #fff;
15 | background-color: #000;
16 | }
17 |
--------------------------------------------------------------------------------
/Secrets - Starting Code/views/home.ejs:
--------------------------------------------------------------------------------
1 | <%- include('partials/header') %>
2 |
3 |
4 |
5 |
6 |
7 |
Secrets
8 |
Don't keep your secrets, share them anonymously!
9 |
10 |
Register
11 |
Login
12 |
13 |
14 |
15 |
16 | <%- include('partials/footer') %>
17 |
--------------------------------------------------------------------------------
/Secrets - Starting Code/views/login.ejs:
--------------------------------------------------------------------------------
1 | <%- include('partials/header') %>
2 |
3 |
41 |
42 | <%- include('partials/footer') %>
43 |
--------------------------------------------------------------------------------
/Secrets - Starting Code/views/partials/footer.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |