This project was generated with Angular CLI.
This is a simple login page made with MEAN stack (MongoDB, ExpressJS, Angular 6, NodeJS).
- User registration.
- User login.
- User Authorization.
- When user enters email and password and when both of them are correct we return an access token (generated with jwt)
- This access token is stored in localstorage of the browser.
- Now if user leaves the page and opens the same site again we check to see if there is any access token present in user's localstorage.
- if access token is present - > we verify that access token and redirect user to the profile page.
- if access token is not present - > we keep user on the same page.
- NodeJS and ExpressJS is inside
restApi/
- MongoDB database is in
user_db/
- Angular Components are in
src/app
- MEAN stack (Angular 2+)
- ES6 Javascript (specially promises)
- JWT: Json Web Token it is a libray to generate random token it has 2 function jwt.sign() to create token and jwt.verify() to verify
- bcrypt - Library to hash passwords, I've used two functions in this project bcrypt.hash() to hash password and bcrypt.compare to compare string with hashed password.
- Install npm and Angular Client
npm install @angular/cli
(ignore if already installed) - In command prompt type
npm install
to download starter packages. cd restApi
and typenpm install bcrypt,jsonwebtoken,mongoose,express
- Install MongoDB
- Go to bin folder in your mongodb directory, Mine is in
c:/program files/mongodb/server/3.6/bin
and typemongostore <path of user_db folder>
- Change directory to your project and
ng serve
to start angular server - Change directory to bin folder of your mongodb installation folder, Mine is
c:/program files/mongodb/server/3.6/bin
and typemongod
then open new command prompt and typemongo
- Change directory to
restApi/
and typenode index.js
to start Node Server
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
Run ng generate component component-name
to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module
.
Run ng build
to build the project. The build artifacts will be stored in the dist/
directory. Use the -prod
flag for a production build.
Run ng test
to execute the unit tests via Karma.
Run ng e2e
to execute the end-to-end tests via Protractor.
To get more help on the Angular CLI use ng help
or go check out the Angular CLI README.