Professional Documents
Culture Documents
Login: Login Card in Login - Hbs
Login: Login Card in Login - Hbs
Login: Login Card in Login - Hbs
Create a Route in index.js so that we can render some views-get for login,dashboard
views-dashboard.hbs,login.hbs to render views or templates
added cdn in main.hbs
static folder
all routes imported to app.js
2 layouts -one for login page because not going to have navbar
-login.hbs,main.hbs
LOGIN
WE CANNOT DO ANYTHING WITHOUT LOGGING IN.If I try to go to
/stories or /anything it’s just going to bounce me back.so I need to
login
set up morgan for login bring in morgan to page app.js
TYPE ROUTES
if after logout we type /dashboard we go there and if we login and
type /login we can go there.
To avoid this we created
a piece of middleware(fxn that has access to request and response
objects)
and protected routes. middleware folder-->auth.js-->creating fxn.
RELOAD
if we reload dashboard kicks me out.To prevent this storing sessions in
database with connect-mongo extension in app.js and pass session
if we go to db we can see sessions .
NAVBAR
for navbar _header.hbs it's partial it's being inserted into another view
and then insert partial in main.hbs with {{>header}}
when we logout this goes to auth logout.
CK EDITOR
using ck editor using cdn for that and put in main.hbs
REQUESTS
make this form do put req for update/edit/delete because we want
updates in server.db
we going to keep method post but middleware method-override going
to replace that with whatever we put stories.js--edit.hbs
delete using method post although not really post because using
override
read more--get request to story/id
LOGOUT
logout in auth.js ,with passport middleware once we login we will have
logout method on the request object so
we can just simply call that request logout and then after we logout
let's just redirect to home page
Models-Story.js
index.js
ROUTES DESCRIPTION
GET/ Login Page
GET/DASHBOARD Dashboard Page
GET/auth/google Authenticate with Google
GET/auth/google/callback Google auth callback
/auth/logout Logout user
GET/stories/add Show add page
POST/stories Process add form
GET/stories Show all stories
GET/stories/edit/:id Show edit page
PUT/stories/:id Update story
DELETE/stories/:id Delete story
GET/stories/:id Show single story
GET/stories/user/:userId User stories