Danial Khosravi's Blog

Entrepreneur in the making...

Authentication Using PassportJS

| Comments

As I promised before, today i’m going to talk about authentication with PassportJS. Passport is one of the capable node modules which can be used for local authentication or even using it for integrating with Facebook or Twitter and …

Basically in passport we set up some strategies and then pass the passport middleware into our application and then passport will take care of most of the things.

Strategies can be local for your local authentication , or Facebook for authentication with Facebook .

I’m going talk about Passport API a little bit and building a sample app which have local, Facebook and Twitter authentication. And also i’m going to use MongoDB as database of this application.

Application Overview :

  1. Installing Passport and adding to app
  2. Adding passport middlewares
  3. Database and Models
  4. Setting the strategies
  5. Function Handlers
  6. Routes

Simple Authentication in NodeJS

| Comments

Hi everyone !!

Today i’m going to show you my simple authentication practice. There is lots of good authentication modules out there which can be used as middleware like PassportJS and Everyauth and they are also very useful for integration your web site with social networks like Facebook and Twitter. I will cover both the mentions tools in future posts but today we are going to build our authentication functionality on our own !!

Before we start I should mention that like always I used MongoDB as a database for saving and loading our users. And I integrate it with our app using Mongoose module. So make sure you have them installed or if you using my source files first run npm install . Also make sure you are running mongo server by running mongod in new shell.

Application Parts

  • Module Dependencies
  • Database and Models
  • Middlewares and configurations
  • Helper Functions
  • Routes

Simple Node Server

| Comments

Hello

In my first post on my brand new blog I want to talk about my new discoveries on NodeJS. As you can see in NodeJs site :

Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.

Its a lot great features that all are 100% JavaScript . Definitely it’s a great choice for a beginner like me that only know a bit of JavaScrip. With Node you can run your server side JavaScript codes easily !!


What We Are Going To See?

I’m going to show you how to make a simple server. For now I just render two pages on this server, home and about. It’s all with pure NodeJS and I don’t use any framework. If you are familiar with amazing framework of NodeJS, Express you would say it could be much more easier with Express. I agree but I believe first we should learn how to deal with NodeJS and after that go for frameworks.

By the way i’m going to cover Express in future posts in this blog !!