Auth & Project Night 2
Leon Noel
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/7626184/Learn_with_Leon_v2__bonus_.png)
#100Devs
"Who is that surrounding me?
Enemy, enemy you crossed the wrong boundary, poof!
Wicked witness wizardry
Disappear from here and end up in a tree
Crossed the wrong boundary"
Agenda
-
Questions?
-
Let's Talk - #100Devs
-
Due - Professional Checklist
-
Learn - Local Auth
-
Build - Project Night
-
Homework - Start Interview Prep
Questions
About last class or life
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/7634660/how-dare.gif)
Checking In
![](https://media2.giphy.com/media/BmmfETghGOPrW/giphy.gif)
Like and Retweet the Tweet
!checkin
Submitting Work
![](https://media3.giphy.com/media/26uf7rl7j6RVibDz2/giphy.gif)
I WANT IT - CHECKLIST
Homework: https://forms.gle/MUdE5XCY7VGKup1y8
Please Triple Check Before You Submit! No incomplete / fake work. It just makes my life more difficult and won't help you...
BACKEND REVIEW CLASS
![](https://media3.giphy.com/media/5wWf7GW1AzV6pF3MaVW/giphy.gif)
SUNDAY Sept 11th
1:00pm EST
Authentication? Logged In Users? HOW?
![](https://media3.giphy.com/media/xUA7bilj5YByXZkqnS/giphy.gif)
MVC
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/9810849/mvc.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/8462211/mvc.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/8462211/mvc.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/9810551/Screen_Shot_2022-09-01_at_11.54.42_AM.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/9810570/Screen_Shot_2022-09-01_at_11.59.36_AM.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/9810578/Screen_Shot_2022-09-01_at_12.03.04_PM.png)
Step 1: Go to File > Preferences > Settings
Step 2: search for "workbench.editor.labelFormat"
Step 3: select medium from a drop-down
![](https://media0.giphy.com/media/yJFeycRK2DB4c/giphy.gif)
Client Makes A Request
![](https://media0.giphy.com/media/m2Q7FEc0bEr4I/giphy.gif)
Client
Server
someurl.com/todos
Loggining In or Signing Up redirects you to
Server Is Setup To Hear That Request
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/9810770/Screen_Shot_2022-09-01_at_1.09.44_PM.png)
Server
Running Code
We Wrote
To Handle The Request
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/9810770/Screen_Shot_2022-09-01_at_1.09.44_PM.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/9810771/Screen_Shot_2022-09-01_at_1.10.10_PM.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/9810858/Screen_Shot_2022-09-01_at_1.45.23_PM.png)
Bottom of server.js file
Top of server.js file
routes/todos.js
Router Hears The Request
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/9810771/Screen_Shot_2022-09-01_at_1.10.10_PM.png)
routes/todos.js
WHAT TYPE OF REQUEST WAS IT?
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/9810771/Screen_Shot_2022-09-01_at_1.10.10_PM.png)
routes/todos.js
Check If Logged In
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/9810771/Screen_Shot_2022-09-01_at_1.10.10_PM.png)
routes/todos.js
ARE YOU LOGGED IN?
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/9810824/Screen_Shot_2022-09-01_at_1.30.19_PM.png)
middleware/auth.js
Ok, logged in, but what controller?
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/9810771/Screen_Shot_2022-09-01_at_1.10.10_PM.png)
routes/todos.js
Controllaaa
![](https://media1.giphy.com/media/awRkupqDLdLna/giphy.gif)
Which METHOD tho...
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/9810921/Screen_Shot_2022-09-01_at_2.05.07_PM.png)
controllers/todos.js
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/9810771/Screen_Shot_2022-09-01_at_1.10.10_PM.png)
routes/todos.js
![](https://media2.giphy.com/media/XAdbHJywVjF5K/giphy.gif)
Who is logged in?
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/9810921/Screen_Shot_2022-09-01_at_2.05.07_PM.png)
controllers/todos.js
SHOW ME THAT REQUEST
![](https://media1.giphy.com/media/AmB1h0yAniXEvrXJ8C/giphy.gif)
How do I get the todos?
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/9810921/Screen_Shot_2022-09-01_at_2.05.07_PM.png)
controllers/todos.js
MONGOOSE
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/9810929/Screen_Shot_2022-09-01_at_2.10.05_PM.png)
![](https://media3.giphy.com/media/vNdHTvHo3gCis/giphy.gif)
models/todos.js
Mongoose
Collection
document
document
document
document
Mongoose provides a straight-forward, schema-based solution to model your application data.
Mongoose
Collection
document
document
document
document
Each schema maps to a MongoDB collection and defines the shape of the documents within that collection.
const UserSchema = new mongoose.Schema({
userName: { type: String, unique: true },
email: { type: String, unique: true },
password: String
})
Mongoose
Collection
document
document
document
document
Models are fancy constructors compiled from Schema definitions. An instance of a model is called a document.
Models are responsible for creating and reading documents from the underlying MongoDB database.
module.exports =
mongoose.model('User', UserSchema)
It Goes Down In The DB
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/9810942/Screen_Shot_2022-09-01_at_2.18.29_PM.png)
Pass It To The Views
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/9810921/Screen_Shot_2022-09-01_at_2.05.07_PM.png)
controllers/todos.js
I was running through...
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/9810948/Screen_Shot_2022-09-01_at_2.14.54_PM.png)
views/todos.ejs
Render THAT
![](https://s3.amazonaws.com/media-p.slid.es/uploads/549074/images/9810921/Screen_Shot_2022-09-01_at_2.05.07_PM.png)
controllers/todos.js
HAPPY USER
![](https://media0.giphy.com/media/CyoQdbc7FHqqTpkSPI/giphy.gif)
![](https://media0.giphy.com/media/GcSqyYa2aF8dy/giphy.gif)
Team Projects!
![](https://media4.giphy.com/media/100PgquHm9j3sQ/giphy.gif)
Homework
Do: Finish Project
![](https://media.giphy.com/media/3oEjI5pYnV0zNvKzXa/source.gif)
#100Devs - Auth & Project Night Part 02 (cohort 2)
By Leon Noel
#100Devs - Auth & Project Night Part 02 (cohort 2)
Class 51 of our Free Web Dev Bootcamp for folx affected by the pandemic. Join live T/Th 6:30pm ET leonnoel.com/twitch and ask questions here: leonnoel.com/discord
- 1,996