├── ngApp
├── .angular-cli.json
├── .editorconfig
├── .gitignore
├── README.md
├── e2e
│ ├── app.e2e-spec.ts
│ ├── app.po.ts
│ └── tsconfig.e2e.json
├── karma.conf.js
├── package-lock.json
├── package.json
├── protractor.conf.js
├── src
│ ├── app
│ │ ├── app-routing.module.ts
│ │ ├── app.component.css
│ │ ├── app.component.html
│ │ ├── app.component.spec.ts
│ │ ├── app.component.ts
│ │ ├── app.module.ts
│ │ ├── auth.guard.spec.ts
│ │ ├── auth.guard.ts
│ │ ├── auth.service.ts
│ │ ├── event.service.ts
│ │ ├── events
│ │ │ ├── events.component.css
│ │ │ ├── events.component.html
│ │ │ ├── events.component.spec.ts
│ │ │ └── events.component.ts
│ │ ├── login
│ │ │ ├── login.component.css
│ │ │ ├── login.component.html
│ │ │ ├── login.component.spec.ts
│ │ │ └── login.component.ts
│ │ ├── register
│ │ │ ├── register.component.css
│ │ │ ├── register.component.html
│ │ │ ├── register.component.spec.ts
│ │ │ └── register.component.ts
│ │ ├── special-events
│ │ │ ├── special-events.component.css
│ │ │ ├── special-events.component.html
│ │ │ ├── special-events.component.spec.ts
│ │ │ └── special-events.component.ts
│ │ └── token-interceptor.service.ts
│ ├── assets
│ │ └── .gitkeep
│ ├── environments
│ │ ├── environment.prod.ts
│ │ └── environment.ts
│ ├── favicon.ico
│ ├── index.html
│ ├── main.ts
│ ├── polyfills.ts
│ ├── styles.css
│ ├── test.ts
│ ├── tsconfig.app.json
│ ├── tsconfig.spec.json
│ └── typings.d.ts
├── tsconfig.json
└── tslint.json
└── server
├── .gitignore
├── models
└── user.js
├── package-lock.json
├── package.json
├── routes
└── api.js
└── server.js
/ngApp/.angular-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "project": {
4 | "name": "ng-app"
5 | },
6 | "apps": [
7 | {
8 | "root": "src",
9 | "outDir": "dist",
10 | "assets": [
11 | "assets",
12 | "favicon.ico"
13 | ],
14 | "index": "index.html",
15 | "main": "main.ts",
16 | "polyfills": "polyfills.ts",
17 | "test": "test.ts",
18 | "tsconfig": "tsconfig.app.json",
19 | "testTsconfig": "tsconfig.spec.json",
20 | "prefix": "app",
21 | "styles": [
22 | "styles.css"
23 | ],
24 | "scripts": [],
25 | "environmentSource": "environments/environment.ts",
26 | "environments": {
27 | "dev": "environments/environment.ts",
28 | "prod": "environments/environment.prod.ts"
29 | }
30 | }
31 | ],
32 | "e2e": {
33 | "protractor": {
34 | "config": "./protractor.conf.js"
35 | }
36 | },
37 | "lint": [
38 | {
39 | "project": "src/tsconfig.app.json",
40 | "exclude": "**/node_modules/**"
41 | },
42 | {
43 | "project": "src/tsconfig.spec.json",
44 | "exclude": "**/node_modules/**"
45 | },
46 | {
47 | "project": "e2e/tsconfig.e2e.json",
48 | "exclude": "**/node_modules/**"
49 | }
50 | ],
51 | "test": {
52 | "karma": {
53 | "config": "./karma.conf.js"
54 | }
55 | },
56 | "defaults": {
57 | "styleExt": "css",
58 | "component": {}
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/ngApp/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/ngApp/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /dist
5 | /dist-server
6 | /tmp
7 | /out-tsc
8 |
9 | # dependencies
10 | /node_modules
11 |
12 | # IDEs and editors
13 | /.idea
14 | .project
15 | .classpath
16 | .c9/
17 | *.launch
18 | .settings/
19 | *.sublime-workspace
20 |
21 | # IDE - VSCode
22 | .vscode/*
23 | !.vscode/settings.json
24 | !.vscode/tasks.json
25 | !.vscode/launch.json
26 | !.vscode/extensions.json
27 |
28 | # misc
29 | /.sass-cache
30 | /connect.lock
31 | /coverage
32 | /libpeerconnection.log
33 | npm-debug.log
34 | testem.log
35 | /typings
36 |
37 | # e2e
38 | /e2e/*.js
39 | /e2e/*.map
40 |
41 | # System Files
42 | .DS_Store
43 | Thumbs.db
44 |
--------------------------------------------------------------------------------
/ngApp/README.md:
--------------------------------------------------------------------------------
1 | # NgApp
2 |
3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.6.6.
4 |
5 | ## Development server
6 |
7 | 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.
8 |
9 | ## Code scaffolding
10 |
11 | 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`.
12 |
13 | ## Build
14 |
15 | 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.
16 |
17 | ## Running unit tests
18 |
19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20 |
21 | ## Running end-to-end tests
22 |
23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
24 |
25 | ## Further help
26 |
27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
28 |
--------------------------------------------------------------------------------
/ngApp/e2e/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { AppPage } from './app.po';
2 |
3 | describe('ng-app App', () => {
4 | let page: AppPage;
5 |
6 | beforeEach(() => {
7 | page = new AppPage();
8 | });
9 |
10 | it('should display welcome message', () => {
11 | page.navigateTo();
12 | expect(page.getParagraphText()).toEqual('Welcome to app!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/ngApp/e2e/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor';
2 |
3 | export class AppPage {
4 | navigateTo() {
5 | return browser.get('/');
6 | }
7 |
8 | getParagraphText() {
9 | return element(by.css('app-root h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/ngApp/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/e2e",
5 | "baseUrl": "./",
6 | "module": "commonjs",
7 | "target": "es5",
8 | "types": [
9 | "jasmine",
10 | "jasminewd2",
11 | "node"
12 | ]
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ngApp/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular/cli'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular/cli/plugins/karma')
14 | ],
15 | client:{
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | reports: [ 'html', 'lcovonly' ],
20 | fixWebpackSourcePaths: true
21 | },
22 | angularCli: {
23 | environment: 'dev'
24 | },
25 | reporters: ['progress', 'kjhtml'],
26 | port: 9876,
27 | colors: true,
28 | logLevel: config.LOG_INFO,
29 | autoWatch: true,
30 | browsers: ['Chrome'],
31 | singleRun: false
32 | });
33 | };
34 |
--------------------------------------------------------------------------------
/ngApp/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ng-app",
3 | "version": "0.0.0",
4 | "license": "MIT",
5 | "scripts": {
6 | "ng": "ng",
7 | "start": "ng serve",
8 | "build": "ng build --prod",
9 | "test": "ng test",
10 | "lint": "ng lint",
11 | "e2e": "ng e2e"
12 | },
13 | "private": true,
14 | "dependencies": {
15 | "@angular/animations": "^5.2.0",
16 | "@angular/common": "^5.2.0",
17 | "@angular/compiler": "^5.2.0",
18 | "@angular/core": "^5.2.0",
19 | "@angular/forms": "^5.2.0",
20 | "@angular/http": "^5.2.0",
21 | "@angular/platform-browser": "^5.2.0",
22 | "@angular/platform-browser-dynamic": "^5.2.0",
23 | "@angular/router": "^5.2.0",
24 | "core-js": "^2.4.1",
25 | "rxjs": "^5.5.6",
26 | "zone.js": "^0.8.19"
27 | },
28 | "devDependencies": {
29 | "@angular/cli": "1.6.6",
30 | "@angular/compiler-cli": "^5.2.0",
31 | "@angular/language-service": "^5.2.0",
32 | "@types/jasmine": "~2.8.3",
33 | "@types/jasminewd2": "~2.0.2",
34 | "@types/node": "~6.0.60",
35 | "codelyzer": "^4.0.1",
36 | "jasmine-core": "~2.8.0",
37 | "jasmine-spec-reporter": "~4.2.1",
38 | "karma": "~2.0.0",
39 | "karma-chrome-launcher": "~2.2.0",
40 | "karma-coverage-istanbul-reporter": "^1.2.1",
41 | "karma-jasmine": "~1.1.0",
42 | "karma-jasmine-html-reporter": "^0.2.2",
43 | "protractor": "~5.1.2",
44 | "ts-node": "~4.1.0",
45 | "tslint": "~5.9.1",
46 | "typescript": "~2.5.3"
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/ngApp/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/lib/config.ts
3 |
4 | const { SpecReporter } = require('jasmine-spec-reporter');
5 |
6 | exports.config = {
7 | allScriptsTimeout: 11000,
8 | specs: [
9 | './e2e/**/*.e2e-spec.ts'
10 | ],
11 | capabilities: {
12 | 'browserName': 'chrome'
13 | },
14 | directConnect: true,
15 | baseUrl: 'http://localhost:4200/',
16 | framework: 'jasmine',
17 | jasmineNodeOpts: {
18 | showColors: true,
19 | defaultTimeoutInterval: 30000,
20 | print: function() {}
21 | },
22 | onPrepare() {
23 | require('ts-node').register({
24 | project: 'e2e/tsconfig.e2e.json'
25 | });
26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
27 | }
28 | };
29 |
--------------------------------------------------------------------------------
/ngApp/src/app/app-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { Routes, RouterModule } from '@angular/router';
3 | import { LoginComponent } from './login/login.component'
4 | import { RegisterComponent } from './register/register.component'
5 | import { EventsComponent } from './events/events.component';
6 | import { SpecialEventsComponent } from './special-events/special-events.component';
7 | import { AuthGuard } from './auth.guard';
8 |
9 | const routes: Routes = [
10 | {
11 | path: '',
12 | redirectTo: '/events',
13 | pathMatch: 'full'
14 | },
15 | {
16 | path: 'events',
17 | component: EventsComponent
18 | },
19 | {
20 | path: 'special',
21 | canActivate: [AuthGuard],
22 | component: SpecialEventsComponent
23 | },
24 | {
25 | path: 'login',
26 | component: LoginComponent
27 | },
28 | {
29 | path: 'register',
30 | component: RegisterComponent
31 | }
32 | ];
33 |
34 | @NgModule({
35 | imports: [RouterModule.forRoot(routes)],
36 | exports: [RouterModule]
37 | })
38 | export class AppRoutingModule { }
39 |
--------------------------------------------------------------------------------
/ngApp/src/app/app.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gopinav/Angular-Authentication-Tutorial/3dd08ff53c3800c9d8a577a260452412d97a0166/ngApp/src/app/app.component.css
--------------------------------------------------------------------------------
/ngApp/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/ngApp/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 | import { RouterTestingModule } from '@angular/router/testing';
3 | import { AppComponent } from './app.component';
4 | describe('AppComponent', () => {
5 | beforeEach(async(() => {
6 | TestBed.configureTestingModule({
7 | imports: [
8 | RouterTestingModule
9 | ],
10 | declarations: [
11 | AppComponent
12 | ],
13 | }).compileComponents();
14 | }));
15 | it('should create the app', async(() => {
16 | const fixture = TestBed.createComponent(AppComponent);
17 | const app = fixture.debugElement.componentInstance;
18 | expect(app).toBeTruthy();
19 | }));
20 | it(`should have as title 'app'`, async(() => {
21 | const fixture = TestBed.createComponent(AppComponent);
22 | const app = fixture.debugElement.componentInstance;
23 | expect(app.title).toEqual('app');
24 | }));
25 | it('should render title in a h1 tag', async(() => {
26 | const fixture = TestBed.createComponent(AppComponent);
27 | fixture.detectChanges();
28 | const compiled = fixture.debugElement.nativeElement;
29 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
30 | }));
31 | });
32 |
--------------------------------------------------------------------------------
/ngApp/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 | import { AuthService } from './auth.service';
3 |
4 | @Component({
5 | selector: 'app-root',
6 | templateUrl: './app.component.html',
7 | styleUrls: ['./app.component.css']
8 | })
9 | export class AppComponent {
10 | title = 'app';
11 | constructor(private _authService: AuthService){}
12 | }
13 |
--------------------------------------------------------------------------------
/ngApp/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { AuthGuard } from './auth.guard';
2 | import { BrowserModule } from '@angular/platform-browser';
3 | import { NgModule } from '@angular/core';
4 | import { FormsModule } from '@angular/forms';
5 | import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
6 | import { AppRoutingModule } from './app-routing.module';
7 |
8 | import { AppComponent } from './app.component';
9 | import { LoginComponent } from './login/login.component';
10 | import { RegisterComponent } from './register/register.component';
11 | import { EventsComponent } from './events/events.component';
12 | import { SpecialEventsComponent } from './special-events/special-events.component';
13 | import { AuthService } from './auth.service';
14 | import { EventService } from './event.service';
15 | import { TokenInterceptorService } from './token-interceptor.service';
16 |
17 |
18 | @NgModule({
19 | declarations: [
20 | AppComponent,
21 | LoginComponent,
22 | RegisterComponent,
23 | EventsComponent,
24 | SpecialEventsComponent
25 | ],
26 | imports: [
27 | BrowserModule,
28 | FormsModule,
29 | HttpClientModule,
30 | AppRoutingModule
31 | ],
32 | providers: [AuthService, AuthGuard, EventService,
33 | {
34 | provide: HTTP_INTERCEPTORS,
35 | useClass: TokenInterceptorService,
36 | multi: true
37 | }],
38 | bootstrap: [AppComponent]
39 | })
40 | export class AppModule { }
41 |
--------------------------------------------------------------------------------
/ngApp/src/app/auth.guard.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async, inject } from '@angular/core/testing';
2 |
3 | import { AuthGuard } from './auth.guard';
4 |
5 | describe('AuthGuard', () => {
6 | beforeEach(() => {
7 | TestBed.configureTestingModule({
8 | providers: [AuthGuard]
9 | });
10 | });
11 |
12 | it('should ...', inject([AuthGuard], (guard: AuthGuard) => {
13 | expect(guard).toBeTruthy();
14 | }));
15 | });
16 |
--------------------------------------------------------------------------------
/ngApp/src/app/auth.guard.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { CanActivate, Router } from '@angular/router';
3 | import { AuthService } from './auth.service';
4 |
5 | @Injectable()
6 | export class AuthGuard implements CanActivate {
7 | constructor(private _authService: AuthService,
8 | private _router: Router) { }
9 |
10 | canActivate(): boolean {
11 | if (this._authService.loggedIn()) {
12 | console.log('true')
13 | return true
14 | } else {
15 | console.log('false')
16 | this._router.navigate(['/login'])
17 | return false
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/ngApp/src/app/auth.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { HttpClient } from '@angular/common/http'
3 | import { Router } from '@angular/router'
4 |
5 | @Injectable()
6 | export class AuthService {
7 |
8 | private _registerUrl = "http://localhost:3000/api/register";
9 | private _loginUrl = "http://localhost:3000/api/login";
10 |
11 | constructor(private http: HttpClient,
12 | private _router: Router) { }
13 |
14 | registerUser(user) {
15 | return this.http.post(this._registerUrl, user)
16 | }
17 |
18 | loginUser(user) {
19 | return this.http.post(this._loginUrl, user)
20 | }
21 |
22 | logoutUser() {
23 | localStorage.removeItem('token')
24 | this._router.navigate(['/events'])
25 | }
26 |
27 | getToken() {
28 | return localStorage.getItem('token')
29 | }
30 |
31 | loggedIn() {
32 | return !!localStorage.getItem('token')
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/ngApp/src/app/event.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { HttpClient } from '@angular/common/http'
3 |
4 | @Injectable()
5 | export class EventService {
6 |
7 | private _eventsUrl = "http://localhost:3000/api/events";
8 | private _specialEventsUrl = "http://localhost:3000/api/special";
9 |
10 | constructor(private http: HttpClient) { }
11 |
12 | getEvents() {
13 | return this.http.get(this._eventsUrl)
14 | }
15 |
16 | getSpecialEvents() {
17 | return this.http.get(this._specialEventsUrl)
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ngApp/src/app/events/events.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gopinav/Angular-Authentication-Tutorial/3dd08ff53c3800c9d8a577a260452412d97a0166/ngApp/src/app/events/events.component.css
--------------------------------------------------------------------------------
/ngApp/src/app/events/events.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
{{event.name}}
6 |
{{event.description}}
7 |
Buy Tickets
8 |
9 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ngApp/src/app/events/events.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { EventsComponent } from './events.component';
4 |
5 | describe('EventsComponent', () => {
6 | let component: EventsComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ EventsComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(EventsComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/ngApp/src/app/events/events.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { EventService } from '../event.service';
3 |
4 | @Component({
5 | selector: 'app-events',
6 | templateUrl: './events.component.html',
7 | styleUrls: ['./events.component.css']
8 | })
9 | export class EventsComponent implements OnInit {
10 |
11 | events = []
12 | constructor(private _eventService: EventService) { }
13 |
14 | ngOnInit() {
15 | this._eventService.getEvents()
16 | .subscribe(
17 | res => this.events = res,
18 | err => console.log(err)
19 | )
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/ngApp/src/app/login/login.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gopinav/Angular-Authentication-Tutorial/3dd08ff53c3800c9d8a577a260452412d97a0166/ngApp/src/app/login/login.component.css
--------------------------------------------------------------------------------
/ngApp/src/app/login/login.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/ngApp/src/app/login/login.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { LoginComponent } from './login.component';
4 |
5 | describe('LoginComponent', () => {
6 | let component: LoginComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ LoginComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(LoginComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/ngApp/src/app/login/login.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { AuthService } from '../auth.service';
3 | import { Router } from '@angular/router'
4 |
5 |
6 | @Component({
7 | selector: 'app-login',
8 | templateUrl: './login.component.html',
9 | styleUrls: ['./login.component.css']
10 | })
11 | export class LoginComponent implements OnInit {
12 |
13 | loginUserData = {}
14 |
15 | constructor(private _auth: AuthService,
16 | private _router: Router) { }
17 |
18 | ngOnInit() {
19 | }
20 |
21 | loginUser () {
22 | this._auth.loginUser(this.loginUserData)
23 | .subscribe(
24 | res => {
25 | localStorage.setItem('token', res.token)
26 | this._router.navigate(['/special'])
27 | },
28 | err => console.log(err)
29 | )
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/ngApp/src/app/register/register.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gopinav/Angular-Authentication-Tutorial/3dd08ff53c3800c9d8a577a260452412d97a0166/ngApp/src/app/register/register.component.css
--------------------------------------------------------------------------------
/ngApp/src/app/register/register.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/ngApp/src/app/register/register.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { RegisterComponent } from './register.component';
4 |
5 | describe('RegisterComponent', () => {
6 | let component: RegisterComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ RegisterComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(RegisterComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/ngApp/src/app/register/register.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { AuthService } from '../auth.service';
3 | import { Router } from '@angular/router'
4 |
5 | @Component({
6 | selector: 'app-register',
7 | templateUrl: './register.component.html',
8 | styleUrls: ['./register.component.css']
9 | })
10 | export class RegisterComponent implements OnInit {
11 |
12 | registerUserData = {}
13 | constructor(private _auth: AuthService,
14 | private _router: Router) { }
15 |
16 | ngOnInit() {
17 | }
18 |
19 | registerUser() {
20 | this._auth.registerUser(this.registerUserData)
21 | .subscribe(
22 | res => {
23 | localStorage.setItem('token', res.token)
24 | this._router.navigate(['/special'])
25 | },
26 | err => console.log(err)
27 | )
28 | }
29 |
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/ngApp/src/app/special-events/special-events.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gopinav/Angular-Authentication-Tutorial/3dd08ff53c3800c9d8a577a260452412d97a0166/ngApp/src/app/special-events/special-events.component.css
--------------------------------------------------------------------------------
/ngApp/src/app/special-events/special-events.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
{{event.name}}
6 |
{{event.description}}
7 |
Buy Tickets
8 |
9 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ngApp/src/app/special-events/special-events.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { SpecialEventsComponent } from './special-events.component';
4 |
5 | describe('SpecialEventsComponent', () => {
6 | let component: SpecialEventsComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ SpecialEventsComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(SpecialEventsComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/ngApp/src/app/special-events/special-events.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { EventService } from '../event.service';
3 | import { HttpErrorResponse } from '@angular/common/http';
4 | import { Router } from '@angular/router'
5 |
6 | @Component({
7 | selector: 'app-special-events',
8 | templateUrl: './special-events.component.html',
9 | styleUrls: ['./special-events.component.css']
10 | })
11 | export class SpecialEventsComponent implements OnInit {
12 |
13 | specialEvents = []
14 |
15 | constructor(private _eventService: EventService,
16 | private _router: Router) { }
17 |
18 |
19 | ngOnInit() {
20 | this._eventService.getSpecialEvents()
21 | .subscribe(
22 | res => this.specialEvents = res,
23 | err => {
24 | if( err instanceof HttpErrorResponse ) {
25 | if (err.status === 401) {
26 | this._router.navigate(['/login'])
27 | }
28 | }
29 | }
30 | )
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/ngApp/src/app/token-interceptor.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable, Injector } from '@angular/core';
2 | import { HttpInterceptor } from '@angular/common/http'
3 | import { AuthService } from './auth.service';
4 | @Injectable()
5 | export class TokenInterceptorService implements HttpInterceptor {
6 |
7 | constructor(private injector: Injector){}
8 | intercept(req, next) {
9 | let authService = this.injector.get(AuthService)
10 | let tokenizedReq = req.clone(
11 | {
12 | headers: req.headers.set('Authorization', 'bearer ' + authService.getToken())
13 | }
14 | )
15 | return next.handle(tokenizedReq)
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/ngApp/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gopinav/Angular-Authentication-Tutorial/3dd08ff53c3800c9d8a577a260452412d97a0166/ngApp/src/assets/.gitkeep
--------------------------------------------------------------------------------
/ngApp/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/ngApp/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // The file contents for the current environment will overwrite these during build.
2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do
3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead.
4 | // The list of which env maps to which file can be found in `.angular-cli.json`.
5 |
6 | export const environment = {
7 | production: false
8 | };
9 |
--------------------------------------------------------------------------------
/ngApp/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gopinav/Angular-Authentication-Tutorial/3dd08ff53c3800c9d8a577a260452412d97a0166/ngApp/src/favicon.ico
--------------------------------------------------------------------------------
/ngApp/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | NgApp
7 |
8 |
9 |
10 |
11 |
13 |
14 |
15 |
16 |
17 |
19 |
21 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/ngApp/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule)
12 | .catch(err => console.log(err));
13 |
--------------------------------------------------------------------------------
/ngApp/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This file includes polyfills needed by Angular and is loaded before the app.
3 | * You can add your own extra polyfills to this file.
4 | *
5 | * This file is divided into 2 sections:
6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8 | * file.
9 | *
10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/
22 | // import 'core-js/es6/symbol';
23 | // import 'core-js/es6/object';
24 | // import 'core-js/es6/function';
25 | // import 'core-js/es6/parse-int';
26 | // import 'core-js/es6/parse-float';
27 | // import 'core-js/es6/number';
28 | // import 'core-js/es6/math';
29 | // import 'core-js/es6/string';
30 | // import 'core-js/es6/date';
31 | // import 'core-js/es6/array';
32 | // import 'core-js/es6/regexp';
33 | // import 'core-js/es6/map';
34 | // import 'core-js/es6/weak-map';
35 | // import 'core-js/es6/set';
36 |
37 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
38 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
39 |
40 | /** IE10 and IE11 requires the following for the Reflect API. */
41 | // import 'core-js/es6/reflect';
42 |
43 |
44 | /** Evergreen browsers require these. **/
45 | // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
46 | import 'core-js/es7/reflect';
47 |
48 |
49 | /**
50 | * Required to support Web Animations `@angular/platform-browser/animations`.
51 | * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
52 | **/
53 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
54 |
55 |
56 |
57 | /***************************************************************************************************
58 | * Zone JS is required by default for Angular itself.
59 | */
60 | import 'zone.js/dist/zone'; // Included with Angular CLI.
61 |
62 |
63 |
64 | /***************************************************************************************************
65 | * APPLICATION IMPORTS
66 | */
67 |
--------------------------------------------------------------------------------
/ngApp/src/styles.css:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
--------------------------------------------------------------------------------
/ngApp/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/zone-testing';
4 | import { getTestBed } from '@angular/core/testing';
5 | import {
6 | BrowserDynamicTestingModule,
7 | platformBrowserDynamicTesting
8 | } from '@angular/platform-browser-dynamic/testing';
9 |
10 | declare const require: any;
11 |
12 | // First, initialize the Angular testing environment.
13 | getTestBed().initTestEnvironment(
14 | BrowserDynamicTestingModule,
15 | platformBrowserDynamicTesting()
16 | );
17 | // Then we find all the tests.
18 | const context = require.context('./', true, /\.spec\.ts$/);
19 | // And load the modules.
20 | context.keys().map(context);
21 |
--------------------------------------------------------------------------------
/ngApp/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "baseUrl": "./",
6 | "module": "es2015",
7 | "types": []
8 | },
9 | "exclude": [
10 | "test.ts",
11 | "**/*.spec.ts"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/ngApp/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "baseUrl": "./",
6 | "module": "commonjs",
7 | "types": [
8 | "jasmine",
9 | "node"
10 | ]
11 | },
12 | "files": [
13 | "test.ts"
14 | ],
15 | "include": [
16 | "**/*.spec.ts",
17 | "**/*.d.ts"
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/ngApp/src/typings.d.ts:
--------------------------------------------------------------------------------
1 | /* SystemJS module definition */
2 | declare var module: NodeModule;
3 | interface NodeModule {
4 | id: string;
5 | }
6 |
--------------------------------------------------------------------------------
/ngApp/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "outDir": "./dist/out-tsc",
5 | "sourceMap": true,
6 | "declaration": false,
7 | "moduleResolution": "node",
8 | "emitDecoratorMetadata": true,
9 | "experimentalDecorators": true,
10 | "target": "es5",
11 | "typeRoots": [
12 | "node_modules/@types"
13 | ],
14 | "lib": [
15 | "es2017",
16 | "dom"
17 | ]
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ngApp/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rulesDirectory": [
3 | "node_modules/codelyzer"
4 | ],
5 | "rules": {
6 | "arrow-return-shorthand": true,
7 | "callable-types": true,
8 | "class-name": true,
9 | "comment-format": [
10 | true,
11 | "check-space"
12 | ],
13 | "curly": true,
14 | "deprecation": {
15 | "severity": "warn"
16 | },
17 | "eofline": true,
18 | "forin": true,
19 | "import-blacklist": [
20 | true,
21 | "rxjs",
22 | "rxjs/Rx"
23 | ],
24 | "import-spacing": true,
25 | "indent": [
26 | true,
27 | "spaces"
28 | ],
29 | "interface-over-type-literal": true,
30 | "label-position": true,
31 | "max-line-length": [
32 | true,
33 | 140
34 | ],
35 | "member-access": false,
36 | "member-ordering": [
37 | true,
38 | {
39 | "order": [
40 | "static-field",
41 | "instance-field",
42 | "static-method",
43 | "instance-method"
44 | ]
45 | }
46 | ],
47 | "no-arg": true,
48 | "no-bitwise": true,
49 | "no-console": [
50 | true,
51 | "debug",
52 | "info",
53 | "time",
54 | "timeEnd",
55 | "trace"
56 | ],
57 | "no-construct": true,
58 | "no-debugger": true,
59 | "no-duplicate-super": true,
60 | "no-empty": false,
61 | "no-empty-interface": true,
62 | "no-eval": true,
63 | "no-inferrable-types": [
64 | true,
65 | "ignore-params"
66 | ],
67 | "no-misused-new": true,
68 | "no-non-null-assertion": true,
69 | "no-shadowed-variable": true,
70 | "no-string-literal": false,
71 | "no-string-throw": true,
72 | "no-switch-case-fall-through": true,
73 | "no-trailing-whitespace": true,
74 | "no-unnecessary-initializer": true,
75 | "no-unused-expression": true,
76 | "no-use-before-declare": true,
77 | "no-var-keyword": true,
78 | "object-literal-sort-keys": false,
79 | "one-line": [
80 | true,
81 | "check-open-brace",
82 | "check-catch",
83 | "check-else",
84 | "check-whitespace"
85 | ],
86 | "prefer-const": true,
87 | "quotemark": [
88 | true,
89 | "single"
90 | ],
91 | "radix": true,
92 | "semicolon": [
93 | true,
94 | "always"
95 | ],
96 | "triple-equals": [
97 | true,
98 | "allow-null-check"
99 | ],
100 | "typedef-whitespace": [
101 | true,
102 | {
103 | "call-signature": "nospace",
104 | "index-signature": "nospace",
105 | "parameter": "nospace",
106 | "property-declaration": "nospace",
107 | "variable-declaration": "nospace"
108 | }
109 | ],
110 | "unified-signatures": true,
111 | "variable-name": false,
112 | "whitespace": [
113 | true,
114 | "check-branch",
115 | "check-decl",
116 | "check-operator",
117 | "check-separator",
118 | "check-type"
119 | ],
120 | "directive-selector": [
121 | true,
122 | "attribute",
123 | "app",
124 | "camelCase"
125 | ],
126 | "component-selector": [
127 | true,
128 | "element",
129 | "app",
130 | "kebab-case"
131 | ],
132 | "no-output-on-prefix": true,
133 | "use-input-property-decorator": true,
134 | "use-output-property-decorator": true,
135 | "use-host-property-decorator": true,
136 | "no-input-rename": true,
137 | "no-output-rename": true,
138 | "use-life-cycle-interface": true,
139 | "use-pipe-transform-interface": true,
140 | "component-class-suffix": true,
141 | "directive-class-suffix": true
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/server/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /dist
5 | /dist-server
6 | /tmp
7 | /out-tsc
8 |
9 | # dependencies
10 | /node_modules
11 |
12 | # IDEs and editors
13 | /.idea
14 | .project
15 | .classpath
16 | .c9/
17 | *.launch
18 | .settings/
19 | *.sublime-workspace
20 |
21 | # IDE - VSCode
22 | .vscode/*
23 | !.vscode/settings.json
24 | !.vscode/tasks.json
25 | !.vscode/launch.json
26 | !.vscode/extensions.json
27 |
28 | # misc
29 | /.sass-cache
30 | /connect.lock
31 | /coverage
32 | /libpeerconnection.log
33 | npm-debug.log
34 | testem.log
35 | /typings
36 |
37 | # e2e
38 | /e2e/*.js
39 | /e2e/*.map
40 |
41 | # System Files
42 | .DS_Store
43 | Thumbs.db
44 |
--------------------------------------------------------------------------------
/server/models/user.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose');
2 |
3 | const Schema = mongoose.Schema;
4 |
5 | const userSchema = new Schema({
6 | email: String,
7 | password: String,
8 | });
9 |
10 | module.exports = mongoose.model('user', userSchema, 'users');
--------------------------------------------------------------------------------
/server/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "server",
3 | "version": "1.0.0",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "accepts": {
8 | "version": "1.3.4",
9 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.4.tgz",
10 | "integrity": "sha1-hiRnWMfdbSGmR0/whKR0DsBesh8=",
11 | "requires": {
12 | "mime-types": "2.1.17",
13 | "negotiator": "0.6.1"
14 | }
15 | },
16 | "array-flatten": {
17 | "version": "1.1.1",
18 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
19 | "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
20 | },
21 | "async": {
22 | "version": "2.1.4",
23 | "resolved": "https://registry.npmjs.org/async/-/async-2.1.4.tgz",
24 | "integrity": "sha1-LSFgx3iAMuTdbL4lAvH5osj2zeQ=",
25 | "requires": {
26 | "lodash": "4.17.5"
27 | }
28 | },
29 | "base64url": {
30 | "version": "2.0.0",
31 | "resolved": "https://registry.npmjs.org/base64url/-/base64url-2.0.0.tgz",
32 | "integrity": "sha1-6sFuA+oUOO/5Qj1puqNiYu0fcLs="
33 | },
34 | "bluebird": {
35 | "version": "3.5.0",
36 | "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.0.tgz",
37 | "integrity": "sha1-eRQg1/VR7qKJdFOop3ZT+WYG1nw="
38 | },
39 | "body-parser": {
40 | "version": "1.18.2",
41 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz",
42 | "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=",
43 | "requires": {
44 | "bytes": "3.0.0",
45 | "content-type": "1.0.4",
46 | "debug": "2.6.9",
47 | "depd": "1.1.2",
48 | "http-errors": "1.6.2",
49 | "iconv-lite": "0.4.19",
50 | "on-finished": "2.3.0",
51 | "qs": "6.5.1",
52 | "raw-body": "2.3.2",
53 | "type-is": "1.6.15"
54 | }
55 | },
56 | "bson": {
57 | "version": "1.0.4",
58 | "resolved": "https://registry.npmjs.org/bson/-/bson-1.0.4.tgz",
59 | "integrity": "sha1-k8ENOeqltYQVy8QFLz5T5WKwtyw="
60 | },
61 | "buffer-equal-constant-time": {
62 | "version": "1.0.1",
63 | "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
64 | "integrity": "sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk="
65 | },
66 | "bytes": {
67 | "version": "3.0.0",
68 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz",
69 | "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg="
70 | },
71 | "content-disposition": {
72 | "version": "0.5.2",
73 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz",
74 | "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ="
75 | },
76 | "content-type": {
77 | "version": "1.0.4",
78 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
79 | "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA=="
80 | },
81 | "cookie": {
82 | "version": "0.3.1",
83 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz",
84 | "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s="
85 | },
86 | "cookie-signature": {
87 | "version": "1.0.6",
88 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
89 | "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
90 | },
91 | "cors": {
92 | "version": "2.8.4",
93 | "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.4.tgz",
94 | "integrity": "sha1-K9OB8usgECAQXNUOpZ2mMJBpRoY=",
95 | "requires": {
96 | "object-assign": "4.1.1",
97 | "vary": "1.1.2"
98 | }
99 | },
100 | "debug": {
101 | "version": "2.6.9",
102 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
103 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
104 | "requires": {
105 | "ms": "2.0.0"
106 | },
107 | "dependencies": {
108 | "ms": {
109 | "version": "2.0.0",
110 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
111 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
112 | }
113 | }
114 | },
115 | "depd": {
116 | "version": "1.1.2",
117 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
118 | "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak="
119 | },
120 | "destroy": {
121 | "version": "1.0.4",
122 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
123 | "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
124 | },
125 | "ecdsa-sig-formatter": {
126 | "version": "1.0.9",
127 | "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.9.tgz",
128 | "integrity": "sha1-S8kmJ07Dtau1AW5+HWCSGsJisqE=",
129 | "requires": {
130 | "base64url": "2.0.0",
131 | "safe-buffer": "5.1.1"
132 | }
133 | },
134 | "ee-first": {
135 | "version": "1.1.1",
136 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
137 | "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
138 | },
139 | "encodeurl": {
140 | "version": "1.0.2",
141 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
142 | "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
143 | },
144 | "escape-html": {
145 | "version": "1.0.3",
146 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
147 | "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
148 | },
149 | "etag": {
150 | "version": "1.8.1",
151 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
152 | "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
153 | },
154 | "express": {
155 | "version": "4.16.2",
156 | "resolved": "https://registry.npmjs.org/express/-/express-4.16.2.tgz",
157 | "integrity": "sha1-41xt/i1kt9ygpc1PIXgb4ymeB2w=",
158 | "requires": {
159 | "accepts": "1.3.4",
160 | "array-flatten": "1.1.1",
161 | "body-parser": "1.18.2",
162 | "content-disposition": "0.5.2",
163 | "content-type": "1.0.4",
164 | "cookie": "0.3.1",
165 | "cookie-signature": "1.0.6",
166 | "debug": "2.6.9",
167 | "depd": "1.1.2",
168 | "encodeurl": "1.0.2",
169 | "escape-html": "1.0.3",
170 | "etag": "1.8.1",
171 | "finalhandler": "1.1.0",
172 | "fresh": "0.5.2",
173 | "merge-descriptors": "1.0.1",
174 | "methods": "1.1.2",
175 | "on-finished": "2.3.0",
176 | "parseurl": "1.3.2",
177 | "path-to-regexp": "0.1.7",
178 | "proxy-addr": "2.0.2",
179 | "qs": "6.5.1",
180 | "range-parser": "1.2.0",
181 | "safe-buffer": "5.1.1",
182 | "send": "0.16.1",
183 | "serve-static": "1.13.1",
184 | "setprototypeof": "1.1.0",
185 | "statuses": "1.3.1",
186 | "type-is": "1.6.15",
187 | "utils-merge": "1.0.1",
188 | "vary": "1.1.2"
189 | },
190 | "dependencies": {
191 | "setprototypeof": {
192 | "version": "1.1.0",
193 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz",
194 | "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ=="
195 | },
196 | "statuses": {
197 | "version": "1.3.1",
198 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz",
199 | "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4="
200 | }
201 | }
202 | },
203 | "finalhandler": {
204 | "version": "1.1.0",
205 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.0.tgz",
206 | "integrity": "sha1-zgtoVbRYU+eRsvzGgARtiCU91/U=",
207 | "requires": {
208 | "debug": "2.6.9",
209 | "encodeurl": "1.0.2",
210 | "escape-html": "1.0.3",
211 | "on-finished": "2.3.0",
212 | "parseurl": "1.3.2",
213 | "statuses": "1.3.1",
214 | "unpipe": "1.0.0"
215 | },
216 | "dependencies": {
217 | "statuses": {
218 | "version": "1.3.1",
219 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz",
220 | "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4="
221 | }
222 | }
223 | },
224 | "forwarded": {
225 | "version": "0.1.2",
226 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
227 | "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ="
228 | },
229 | "fresh": {
230 | "version": "0.5.2",
231 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
232 | "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
233 | },
234 | "http-errors": {
235 | "version": "1.6.2",
236 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz",
237 | "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=",
238 | "requires": {
239 | "depd": "1.1.1",
240 | "inherits": "2.0.3",
241 | "setprototypeof": "1.0.3",
242 | "statuses": "1.4.0"
243 | },
244 | "dependencies": {
245 | "depd": {
246 | "version": "1.1.1",
247 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz",
248 | "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k="
249 | }
250 | }
251 | },
252 | "iconv-lite": {
253 | "version": "0.4.19",
254 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz",
255 | "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ=="
256 | },
257 | "inherits": {
258 | "version": "2.0.3",
259 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
260 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
261 | },
262 | "ipaddr.js": {
263 | "version": "1.5.2",
264 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.5.2.tgz",
265 | "integrity": "sha1-1LUFvemUaYfM8PxY2QEP+WB+P6A="
266 | },
267 | "jsonwebtoken": {
268 | "version": "8.1.1",
269 | "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.1.1.tgz",
270 | "integrity": "sha512-+ijVOtfLMlCII8LJkvabaKX3+8tGrGjiCTfzoed2D1b/ebKTO1hIYBQUJHbd9dJ9Fa4kH+dhYEd1qDwyzDLUUw==",
271 | "requires": {
272 | "jws": "3.1.4",
273 | "lodash.includes": "4.3.0",
274 | "lodash.isboolean": "3.0.3",
275 | "lodash.isinteger": "4.0.4",
276 | "lodash.isnumber": "3.0.3",
277 | "lodash.isplainobject": "4.0.6",
278 | "lodash.isstring": "4.0.1",
279 | "lodash.once": "4.1.1",
280 | "ms": "2.1.1",
281 | "xtend": "4.0.1"
282 | }
283 | },
284 | "jwa": {
285 | "version": "1.1.5",
286 | "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.1.5.tgz",
287 | "integrity": "sha1-oFUs4CIHQs1S4VN3SjKQXDDnVuU=",
288 | "requires": {
289 | "base64url": "2.0.0",
290 | "buffer-equal-constant-time": "1.0.1",
291 | "ecdsa-sig-formatter": "1.0.9",
292 | "safe-buffer": "5.1.1"
293 | }
294 | },
295 | "jws": {
296 | "version": "3.1.4",
297 | "resolved": "https://registry.npmjs.org/jws/-/jws-3.1.4.tgz",
298 | "integrity": "sha1-+ei5M46KhHJ31kRLFGT2GIDgUKI=",
299 | "requires": {
300 | "base64url": "2.0.0",
301 | "jwa": "1.1.5",
302 | "safe-buffer": "5.1.1"
303 | }
304 | },
305 | "kareem": {
306 | "version": "2.0.4",
307 | "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.0.4.tgz",
308 | "integrity": "sha512-emosNz0ruOjDkyH2QvnL8m65Mzl8D0IBP3PukQmGl2cjhqMrQajq3OcLdLeBV5GzPfqmsuDQB0WkZOHVhyK6jg=="
309 | },
310 | "lodash": {
311 | "version": "4.17.5",
312 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz",
313 | "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw=="
314 | },
315 | "lodash.get": {
316 | "version": "4.4.2",
317 | "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
318 | "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk="
319 | },
320 | "lodash.includes": {
321 | "version": "4.3.0",
322 | "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz",
323 | "integrity": "sha1-YLuYqHy5I8aMoeUTJUgzFISfVT8="
324 | },
325 | "lodash.isboolean": {
326 | "version": "3.0.3",
327 | "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz",
328 | "integrity": "sha1-bC4XHbKiV82WgC/UOwGyDV9YcPY="
329 | },
330 | "lodash.isinteger": {
331 | "version": "4.0.4",
332 | "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz",
333 | "integrity": "sha1-YZwK89A/iwTDH1iChAt3sRzWg0M="
334 | },
335 | "lodash.isnumber": {
336 | "version": "3.0.3",
337 | "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz",
338 | "integrity": "sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w="
339 | },
340 | "lodash.isplainobject": {
341 | "version": "4.0.6",
342 | "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
343 | "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs="
344 | },
345 | "lodash.isstring": {
346 | "version": "4.0.1",
347 | "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz",
348 | "integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE="
349 | },
350 | "lodash.once": {
351 | "version": "4.1.1",
352 | "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz",
353 | "integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w="
354 | },
355 | "media-typer": {
356 | "version": "0.3.0",
357 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
358 | "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
359 | },
360 | "merge-descriptors": {
361 | "version": "1.0.1",
362 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
363 | "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E="
364 | },
365 | "methods": {
366 | "version": "1.1.2",
367 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
368 | "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
369 | },
370 | "mime": {
371 | "version": "1.4.1",
372 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz",
373 | "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ=="
374 | },
375 | "mime-db": {
376 | "version": "1.30.0",
377 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz",
378 | "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE="
379 | },
380 | "mime-types": {
381 | "version": "2.1.17",
382 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz",
383 | "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=",
384 | "requires": {
385 | "mime-db": "1.30.0"
386 | }
387 | },
388 | "mongodb": {
389 | "version": "3.0.2",
390 | "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.0.2.tgz",
391 | "integrity": "sha512-E50FmpSQchZAimn2uPIegoNoH9UQYR1yiGHtQPmmg8/Ekc97w6owHoqaBoz+assnd9V5LxMzmQ/VEWMsQMgZhQ==",
392 | "requires": {
393 | "mongodb-core": "3.0.2"
394 | }
395 | },
396 | "mongodb-core": {
397 | "version": "3.0.2",
398 | "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.0.2.tgz",
399 | "integrity": "sha512-p1B0qwFQUw6C1OlFJnrOJp8KaX7MuGoogRbTaupRt0y+pPRkMllHWtE9V6i1CDtTvI3/3sy2sQwqWez7zuXEAA==",
400 | "requires": {
401 | "bson": "1.0.4",
402 | "require_optional": "1.0.1"
403 | }
404 | },
405 | "mongoose": {
406 | "version": "5.0.4",
407 | "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.0.4.tgz",
408 | "integrity": "sha512-FHH27E2vXemU0Nb6z3so7mO1/UwEZHyM/XMBJcVkmfpTcKRSZ5CmJoIk12yN/U2pFNFTILVbLFWCTD+mB5kU5w==",
409 | "requires": {
410 | "async": "2.1.4",
411 | "bson": "1.0.4",
412 | "kareem": "2.0.4",
413 | "lodash.get": "4.4.2",
414 | "mongodb": "3.0.2",
415 | "mongoose-legacy-pluralize": "1.0.2",
416 | "mpath": "0.3.0",
417 | "mquery": "3.0.0",
418 | "ms": "2.0.0",
419 | "regexp-clone": "0.0.1",
420 | "sliced": "1.0.1"
421 | },
422 | "dependencies": {
423 | "ms": {
424 | "version": "2.0.0",
425 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
426 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
427 | }
428 | }
429 | },
430 | "mongoose-legacy-pluralize": {
431 | "version": "1.0.2",
432 | "resolved": "https://registry.npmjs.org/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz",
433 | "integrity": "sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ=="
434 | },
435 | "mpath": {
436 | "version": "0.3.0",
437 | "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.3.0.tgz",
438 | "integrity": "sha1-elj3iem1/TyUUgY0FXlg8mvV70Q="
439 | },
440 | "mquery": {
441 | "version": "3.0.0",
442 | "resolved": "https://registry.npmjs.org/mquery/-/mquery-3.0.0.tgz",
443 | "integrity": "sha512-WL1Lk8v4l8VFSSwN3yCzY9TXw+fKVYKn6f+w86TRzOLSE8k1yTgGaLBPUByJQi8VcLbOdnUneFV/y3Kv874pnQ==",
444 | "requires": {
445 | "bluebird": "3.5.0",
446 | "debug": "2.6.9",
447 | "regexp-clone": "0.0.1",
448 | "sliced": "0.0.5"
449 | },
450 | "dependencies": {
451 | "sliced": {
452 | "version": "0.0.5",
453 | "resolved": "https://registry.npmjs.org/sliced/-/sliced-0.0.5.tgz",
454 | "integrity": "sha1-XtwETKTrb3gW1Qui/GPiXY/kcH8="
455 | }
456 | }
457 | },
458 | "ms": {
459 | "version": "2.1.1",
460 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
461 | "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
462 | },
463 | "negotiator": {
464 | "version": "0.6.1",
465 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz",
466 | "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk="
467 | },
468 | "object-assign": {
469 | "version": "4.1.1",
470 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
471 | "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
472 | },
473 | "on-finished": {
474 | "version": "2.3.0",
475 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
476 | "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=",
477 | "requires": {
478 | "ee-first": "1.1.1"
479 | }
480 | },
481 | "parseurl": {
482 | "version": "1.3.2",
483 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz",
484 | "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M="
485 | },
486 | "path-to-regexp": {
487 | "version": "0.1.7",
488 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
489 | "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
490 | },
491 | "proxy-addr": {
492 | "version": "2.0.2",
493 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.2.tgz",
494 | "integrity": "sha1-ZXFQT0e7mI7IGAJT+F3X4UlSvew=",
495 | "requires": {
496 | "forwarded": "0.1.2",
497 | "ipaddr.js": "1.5.2"
498 | }
499 | },
500 | "qs": {
501 | "version": "6.5.1",
502 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz",
503 | "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A=="
504 | },
505 | "range-parser": {
506 | "version": "1.2.0",
507 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz",
508 | "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4="
509 | },
510 | "raw-body": {
511 | "version": "2.3.2",
512 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz",
513 | "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=",
514 | "requires": {
515 | "bytes": "3.0.0",
516 | "http-errors": "1.6.2",
517 | "iconv-lite": "0.4.19",
518 | "unpipe": "1.0.0"
519 | }
520 | },
521 | "regexp-clone": {
522 | "version": "0.0.1",
523 | "resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-0.0.1.tgz",
524 | "integrity": "sha1-p8LgmJH9vzj7sQ03b7cwA+aKxYk="
525 | },
526 | "require_optional": {
527 | "version": "1.0.1",
528 | "resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz",
529 | "integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g==",
530 | "requires": {
531 | "resolve-from": "2.0.0",
532 | "semver": "5.5.0"
533 | }
534 | },
535 | "resolve-from": {
536 | "version": "2.0.0",
537 | "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz",
538 | "integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c="
539 | },
540 | "safe-buffer": {
541 | "version": "5.1.1",
542 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
543 | "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
544 | },
545 | "semver": {
546 | "version": "5.5.0",
547 | "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz",
548 | "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA=="
549 | },
550 | "send": {
551 | "version": "0.16.1",
552 | "resolved": "https://registry.npmjs.org/send/-/send-0.16.1.tgz",
553 | "integrity": "sha512-ElCLJdJIKPk6ux/Hocwhk7NFHpI3pVm/IZOYWqUmoxcgeyM+MpxHHKhb8QmlJDX1pU6WrgaHBkVNm73Sv7uc2A==",
554 | "requires": {
555 | "debug": "2.6.9",
556 | "depd": "1.1.2",
557 | "destroy": "1.0.4",
558 | "encodeurl": "1.0.2",
559 | "escape-html": "1.0.3",
560 | "etag": "1.8.1",
561 | "fresh": "0.5.2",
562 | "http-errors": "1.6.2",
563 | "mime": "1.4.1",
564 | "ms": "2.0.0",
565 | "on-finished": "2.3.0",
566 | "range-parser": "1.2.0",
567 | "statuses": "1.3.1"
568 | },
569 | "dependencies": {
570 | "ms": {
571 | "version": "2.0.0",
572 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
573 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
574 | },
575 | "statuses": {
576 | "version": "1.3.1",
577 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz",
578 | "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4="
579 | }
580 | }
581 | },
582 | "serve-static": {
583 | "version": "1.13.1",
584 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.1.tgz",
585 | "integrity": "sha512-hSMUZrsPa/I09VYFJwa627JJkNs0NrfL1Uzuup+GqHfToR2KcsXFymXSV90hoyw3M+msjFuQly+YzIH/q0MGlQ==",
586 | "requires": {
587 | "encodeurl": "1.0.2",
588 | "escape-html": "1.0.3",
589 | "parseurl": "1.3.2",
590 | "send": "0.16.1"
591 | }
592 | },
593 | "setprototypeof": {
594 | "version": "1.0.3",
595 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz",
596 | "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ="
597 | },
598 | "sliced": {
599 | "version": "1.0.1",
600 | "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz",
601 | "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E="
602 | },
603 | "statuses": {
604 | "version": "1.4.0",
605 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz",
606 | "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew=="
607 | },
608 | "type-is": {
609 | "version": "1.6.15",
610 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz",
611 | "integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=",
612 | "requires": {
613 | "media-typer": "0.3.0",
614 | "mime-types": "2.1.17"
615 | }
616 | },
617 | "unpipe": {
618 | "version": "1.0.0",
619 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
620 | "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
621 | },
622 | "utils-merge": {
623 | "version": "1.0.1",
624 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
625 | "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
626 | },
627 | "vary": {
628 | "version": "1.1.2",
629 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
630 | "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
631 | },
632 | "xtend": {
633 | "version": "4.0.1",
634 | "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
635 | "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68="
636 | }
637 | }
638 | }
639 |
--------------------------------------------------------------------------------
/server/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "server",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "server.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "node server.js"
9 | },
10 | "keywords": [],
11 | "author": "",
12 | "license": "ISC",
13 | "dependencies": {
14 | "body-parser": "^1.18.2",
15 | "cors": "^2.8.4",
16 | "express": "^4.16.2",
17 | "jsonwebtoken": "^8.1.1",
18 | "mongoose": "^5.0.4"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/server/routes/api.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 | const mongoose = require('mongoose');
4 | const User = require('../models/user');
5 | const jwt = require('jsonwebtoken')
6 | const db = "mongodb://testuser:testpw@ds123136.mlab.com:23136/eventsdb";
7 | // mongoose.Promise = global.Promise;
8 |
9 | mongoose.connect(db, function(err){
10 | if(err){
11 | console.error('Error! ' + err)
12 | } else {
13 | console.log('Connected to mongodb')
14 | }
15 | });
16 |
17 | function verifyToken(req, res, next) {
18 | if(!req.headers.authorization) {
19 | return res.status(401).send('Unauthorized request')
20 | }
21 | let token = req.headers.authorization.split(' ')[1]
22 | if(token === 'null') {
23 | return res.status(401).send('Unauthorized request')
24 | }
25 | let payload = jwt.verify(token, 'secretKey')
26 | if(!payload) {
27 | return res.status(401).send('Unauthorized request')
28 | }
29 | req.userId = payload.subject
30 | next()
31 | }
32 |
33 | router.get('/events', (req,res) => {
34 | let events = [
35 | {
36 | "_id": "1",
37 | "name": "Auto Expo",
38 | "description": "lorem ipsum",
39 | "date": "2012-04-23T18:25:43.511Z"
40 | },
41 | {
42 | "_id": "2",
43 | "name": "Auto Expo",
44 | "description": "lorem ipsum",
45 | "date": "2012-04-23T18:25:43.511Z"
46 | },
47 | {
48 | "_id": "3",
49 | "name": "Auto Expo",
50 | "description": "lorem ipsum",
51 | "date": "2012-04-23T18:25:43.511Z"
52 | },
53 | {
54 | "_id": "4",
55 | "name": "Auto Expo",
56 | "description": "lorem ipsum",
57 | "date": "2012-04-23T18:25:43.511Z"
58 | },
59 | {
60 | "_id": "5",
61 | "name": "Auto Expo",
62 | "description": "lorem ipsum",
63 | "date": "2012-04-23T18:25:43.511Z"
64 | },
65 | {
66 | "_id": "6",
67 | "name": "Auto Expo",
68 | "description": "lorem ipsum",
69 | "date": "2012-04-23T18:25:43.511Z"
70 | }
71 | ]
72 | res.json(events)
73 | })
74 |
75 | router.get('/special', verifyToken, (req, res) => {
76 | let specialEvents = [
77 | {
78 | "_id": "1",
79 | "name": "Auto Expo Special",
80 | "description": "lorem ipsum",
81 | "date": "2012-04-23T18:25:43.511Z"
82 | },
83 | {
84 | "_id": "2",
85 | "name": "Auto Expo Special",
86 | "description": "lorem ipsum",
87 | "date": "2012-04-23T18:25:43.511Z"
88 | },
89 | {
90 | "_id": "3",
91 | "name": "Auto Expo Special",
92 | "description": "lorem ipsum",
93 | "date": "2012-04-23T18:25:43.511Z"
94 | },
95 | {
96 | "_id": "4",
97 | "name": "Auto Expo Special",
98 | "description": "lorem ipsum",
99 | "date": "2012-04-23T18:25:43.511Z"
100 | },
101 | {
102 | "_id": "5",
103 | "name": "Auto Expo Special",
104 | "description": "lorem ipsum",
105 | "date": "2012-04-23T18:25:43.511Z"
106 | },
107 | {
108 | "_id": "6",
109 | "name": "Auto Expo Special",
110 | "description": "lorem ipsum",
111 | "date": "2012-04-23T18:25:43.511Z"
112 | }
113 | ]
114 | res.json(specialEvents)
115 | })
116 |
117 | router.post('/register', (req, res) => {
118 | let userData = req.body
119 | let user = new User(userData)
120 | user.save((err, registeredUser) => {
121 | if (err) {
122 | console.log(err)
123 | } else {
124 | let payload = {subject: registeredUser._id}
125 | let token = jwt.sign(payload, 'secretKey')
126 | res.status(200).send({token})
127 | }
128 | })
129 | })
130 |
131 | router.post('/login', (req, res) => {
132 | let userData = req.body
133 | User.findOne({email: userData.email}, (err, user) => {
134 | if (err) {
135 | console.log(err)
136 | } else {
137 | if (!user) {
138 | res.status(401).send('Invalid Email')
139 | } else
140 | if ( user.password !== userData.password) {
141 | res.status(401).send('Invalid Password')
142 | } else {
143 | let payload = {subject: user._id}
144 | let token = jwt.sign(payload, 'secretKey')
145 | res.status(200).send({token})
146 | }
147 | }
148 | })
149 | })
150 |
151 | module.exports = router;
--------------------------------------------------------------------------------
/server/server.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const bodyParser = require('body-parser');
3 | const cors = require('cors')
4 | const path = require('path');
5 |
6 | const api = require('./routes/api');
7 | const port = 3000;
8 |
9 | const app = express();
10 | app.use(cors())
11 | app.use(express.static(path.join(__dirname, 'dist')));
12 |
13 | app.use(bodyParser.json());
14 |
15 | app.use('/api', api);
16 |
17 | // app.get('*', (req, res) => {
18 | // res.sendFile(path.join(__dirname, 'dist/index.html'));
19 | // });
20 |
21 | app.listen(port, function(){
22 | console.log("Server running on localhost:" + port);
23 | });
--------------------------------------------------------------------------------