Skip to main content

Posts

Showing posts with the label authentication

Authentication Project: Secret Page App Part Two (Sign Up Page)

Sign Up Page After a complex set up process, finally we can start to write our routes! Step One: Write register route We will write our register route which will render to a "register" page. In this page, it will have a simple sign up form. Step Two: Create Sign up form We add "register.ejs" in the "views" folder. Then, we create a simple form which the url link will be "/register". Then, we run the app.js and get the "/register", so we can see the form. Step Three: Set up body parser For every form post request, we need to add body parser to make it work. Step Four: Handle user sign up Once users sign up, it will lead them to the secret page. Therefore, we need to write a post route. Inside the post route, we add passport authenticate , which will log the user in and store the correct information and run the serialize method. And we specify to use "local" strategy .  ...

Intro To Authentication: Three Useful Tools Will Make Everything Easier

Authentication is very important for both users and websites. It helps to keep users' information safe and also helps us to manage the accounts. Authentication is also complex because there is a lot of moving pieces that have to fit together in just the right way to make that work. The course introduce three tools to make authentication more quickly and safely. 1. Passport.js Passport.js will make our life easier and make our code shorter. It also helps to make implementation faster. Most importantly, it is used a lot in the real word. 2. Passport Local Passport Local is for username and password. It's about providing this entry point into all sorts of destinations. 3. Passport Local Mongoose This package will help us implement authentication with passport, and it's specially made to work with mongoose. We are also going to use these three tools into a Secret Page App project, which will show in next few posts.