From a37b7b7b95227ed47865585ca589045f52c380a5 Mon Sep 17 00:00:00 2001 From: Sudhir Date: Tue, 6 Mar 2018 11:33:25 +0530 Subject: [PATCH 1/6] Login Component --- code/package.json | 2 + .../content/content.router.module.ts | 2 +- .../users/login/login.component.css | 0 .../users/login/login.component.html | 18 +--- .../users/login/login.component.ts | 5 +- code/src/app/jangular/jangular.module.ts | 5 +- .../jangular/users/login/login.component.html | 51 +++++++----- .../users/login/login.component.spec.ts | 1 - .../jangular/users/login/login.component.ts | 83 +++++++++++++++---- .../jangular/users/services/base.service.ts | 69 +++++++++++++++ code/src/app/jangular/users/services/index.ts | 3 + .../jangular/users/services/login.service.ts | 55 ++++++++++++ code/src/app/jangular/users/users.module.ts | 4 +- 13 files changed, 239 insertions(+), 59 deletions(-) delete mode 100644 code/src/app/clientmodule/users/login/login.component.css rename code/src/app/{clientmodule => jangular}/users/login/login.component.spec.ts (99%) create mode 100644 code/src/app/jangular/users/services/base.service.ts create mode 100644 code/src/app/jangular/users/services/index.ts create mode 100644 code/src/app/jangular/users/services/login.service.ts diff --git a/code/package.json b/code/package.json index 7606a2f..2f472df 100644 --- a/code/package.json +++ b/code/package.json @@ -26,9 +26,11 @@ "@angular/platform-server": "^5.0.0", "@angular/router": "^5.0.0", "@appcarvers/ngx-unitelist": "^0.1.10", + "@jaspero/ng2-alerts": "0.0.7", "bootstrap": "^3.3.7", "core-js": "^2.4.1", "hammerjs": "^2.0.8", + "ng2-alert": "0.0.0", "rxjs": "^5.4.2", "zone.js": "^0.8.14" }, diff --git a/code/src/app/clientmodule/content/content.router.module.ts b/code/src/app/clientmodule/content/content.router.module.ts index ff1abad..7ece82b 100644 --- a/code/src/app/clientmodule/content/content.router.module.ts +++ b/code/src/app/clientmodule/content/content.router.module.ts @@ -7,7 +7,7 @@ import { ArticleComponent } from './article/article.component'; const appRoutes: Routes = [ { path: '', component: ArticlesComponent }, - { path: 'article/:article-alias', component: ArticleComponent } + { path: '**', component: ArticleComponent } ]; @NgModule({ diff --git a/code/src/app/clientmodule/users/login/login.component.css b/code/src/app/clientmodule/users/login/login.component.css deleted file mode 100644 index e69de29..0000000 diff --git a/code/src/app/clientmodule/users/login/login.component.html b/code/src/app/clientmodule/users/login/login.component.html index 259230d..8a429c9 100644 --- a/code/src/app/clientmodule/users/login/login.component.html +++ b/code/src/app/clientmodule/users/login/login.component.html @@ -1,17 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/code/src/app/clientmodule/users/login/login.component.ts b/code/src/app/clientmodule/users/login/login.component.ts index f618d11..8ecb61e 100644 --- a/code/src/app/clientmodule/users/login/login.component.ts +++ b/code/src/app/clientmodule/users/login/login.component.ts @@ -3,9 +3,8 @@ import { FormGroup, FormControl } from '@angular/forms'; @Component({ - selector: 'japp-login', - templateUrl: './login.component.html', - styleUrls: ['./login.component.css'] + selector: 'japp-loginn', + templateUrl: './login.component.html' }) export class LoginComponent implements OnInit { diff --git a/code/src/app/jangular/jangular.module.ts b/code/src/app/jangular/jangular.module.ts index 6e75e40..78b4cae 100644 --- a/code/src/app/jangular/jangular.module.ts +++ b/code/src/app/jangular/jangular.module.ts @@ -1,6 +1,6 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; - +import { HttpModule } from '@angular/http'; import {UsersModule} from './users/users.module'; import { ContentModule } from './content/content.module'; @@ -12,7 +12,8 @@ export { MenuService } from './services/menu.service'; imports: [ CommonModule, UsersModule, - ContentModule + ContentModule, + HttpModule ], declarations: [], providers: [JAngularBaseService], diff --git a/code/src/app/jangular/users/login/login.component.html b/code/src/app/jangular/users/login/login.component.html index bf1d553..f761ff6 100644 --- a/code/src/app/jangular/users/login/login.component.html +++ b/code/src/app/jangular/users/login/login.component.html @@ -1,21 +1,34 @@ -
- - -
+ +
+
+
+

Login

+
+
+ +
+ + + +
- - - - - - - - - Remember me! - - - - - - +
+ + + +
+
+ +
+
\ No newline at end of file diff --git a/code/src/app/clientmodule/users/login/login.component.spec.ts b/code/src/app/jangular/users/login/login.component.spec.ts similarity index 99% rename from code/src/app/clientmodule/users/login/login.component.spec.ts rename to code/src/app/jangular/users/login/login.component.spec.ts index b9b2bc1..fc5f46a 100644 --- a/code/src/app/clientmodule/users/login/login.component.spec.ts +++ b/code/src/app/jangular/users/login/login.component.spec.ts @@ -1,5 +1,4 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - import { LoginComponent } from './login.component'; describe('LoginComponent', () => { diff --git a/code/src/app/jangular/users/login/login.component.ts b/code/src/app/jangular/users/login/login.component.ts index 08235a5..363c539 100644 --- a/code/src/app/jangular/users/login/login.component.ts +++ b/code/src/app/jangular/users/login/login.component.ts @@ -1,31 +1,84 @@ import { Component, OnInit } from '@angular/core'; -import { FormGroup, FormControl } from '@angular/forms'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { LoginService } from "../services/index"; +import { Router } from '@angular/router'; +import { AlertsService } from '@jaspero/ng2-alerts'; -import { AuthService } from '../services/auth.service'; @Component({ selector: 'japp-login', templateUrl: './login.component.html', - styleUrls: ['./login.component.css'], - providers : [ AuthService ] + styleUrls: ['./login.component.css'] }) export class LoginComponent implements OnInit { + invalidLoginFormMessage: any; + isLoginFormValid: boolean = true; + busy1; - loginForm : FormGroup = new FormGroup({ - username : new FormControl(""), - password : new FormControl("") - }); + alertOptions = { + showCloseButton: true, + duration: 50000 + } - constructor( private _authService : AuthService ) { } + constructor(private router: Router, + private LoginService : LoginService, + private _alert: AlertsService + ) { + console.log('In Login Component'); + } ngOnInit() { + if (this.LoginService.isLoggedIn()) { + // Get the logged in user details + console.log('Usser Logged In'); + } + else { + this.LoginService.logout(); + this.LoginService.refreshNav.emit(); + } } - login(){ - console.log(this.loginForm); - this._authService.login(this.loginForm.value).subscribe(data => { - console.log(data); - }); + login = new FormGroup({ + username: new FormControl(null, [Validators.required]), + password: new FormControl(null, [Validators.required]), + }); + + onSubmit({ value, valid }) { + if (valid) { + var username = value.username; + var password = value.password; + this.getLoginKey(username, password) + } } -} + getLoginKey(user, pass) { + this.busy1 = this.LoginService.getAuthenticationKey(user, pass) + .subscribe(result => { + if (result.err_msg) { + this.isLoginFormValid = false; + this.invalidLoginFormMessage = result.err_msg; + this._alert.create("error", this.invalidLoginFormMessage, this.alertOptions); + } + else { + if (result.data.auth) { + // Get the agency details and store in to local storage + localStorage.setItem('auth_token', result.data.auth); + this.LoginService.loggedIn = true; + this._alert.create("info", "You are logged in successfully redirecting....", this.alertOptions); + this.LoginService.getUserDetails(result.data.id) + .subscribe(data => { + console.log('Result of the',data); + if (result.err_msg) { + this._alert.create("error", result.err_msg, this.alertOptions); + } + else { + localStorage.setItem('authorizedUser', JSON.stringify(data.data)); + this.LoginService.refreshNav.emit(); + this.router.navigate(['/profile']); + } + }); + } + } + }); + } +} \ No newline at end of file diff --git a/code/src/app/jangular/users/services/base.service.ts b/code/src/app/jangular/users/services/base.service.ts new file mode 100644 index 0000000..911580a --- /dev/null +++ b/code/src/app/jangular/users/services/base.service.ts @@ -0,0 +1,69 @@ +import { Injectable, EventEmitter } from '@angular/core'; +import { Http, Headers, URLSearchParams, RequestOptionsArgs } from '@angular/http'; +import { environment } from '../../../../environments/environment'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/catch'; +import { Observable } from 'rxjs/Rx'; +import { Router } from '@angular/router'; + +@Injectable() +export class Base { + private loggedIn = false; + public globalHeaders; + refreshNav: EventEmitter = new EventEmitter(); + + constructor(public http: Http, private router: Router) { + console.log('Base Service'); + this.loggedIn = !!localStorage.getItem('auth_token'); + let authToken = localStorage.getItem('auth_token'); + this.globalHeaders = new Headers({ "Authorization": 'Bearer ' + authToken }); + } + + post(url: string, body: any, options) { + return this.http.post(url, body, { headers: options }) + .map(res => { + let response = res.json(); + if (response.err_code == '403') { + this.logout(); + this.router.navigate(['/login']); + return response; + } + else { + return response; + } + }).catch(this.handleErrors); + } + + get(url: string, options) { + return this.http.get(url, { headers: options }) + .map(res => { + let response = res.json(); + if (response.err_code == '403') { + this.logout(); + this.router.navigate(['/login']); + + return response; + } + else { + return response; + } + }).catch(this.handleErrors); + } + + logout() { + localStorage.removeItem('auth_token'); + localStorage.removeItem('authorizedUser'); + this.globalHeaders = new Headers(); + this.loggedIn = false; + } + + handleErrors(error: Response) { + return Observable.throw(error || "Server Error"); + } + + isLoggedIn() { + return this.loggedIn; + } + +} \ No newline at end of file diff --git a/code/src/app/jangular/users/services/index.ts b/code/src/app/jangular/users/services/index.ts new file mode 100644 index 0000000..ad3c713 --- /dev/null +++ b/code/src/app/jangular/users/services/index.ts @@ -0,0 +1,3 @@ +export * from './login.service'; +export * from './base.service'; + diff --git a/code/src/app/jangular/users/services/login.service.ts b/code/src/app/jangular/users/services/login.service.ts new file mode 100644 index 0000000..6f4870e --- /dev/null +++ b/code/src/app/jangular/users/services/login.service.ts @@ -0,0 +1,55 @@ +import { Injectable, EventEmitter } from '@angular/core'; +import { Http, Headers, URLSearchParams } from '@angular/http'; +import { environment } from '../../../../environments/environment'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/catch'; +import { Observable } from 'rxjs/Rx'; +import { Router } from '@angular/router'; +import { Base } from './base.service'; + +@Injectable() +export class LoginService { + public loggedIn = false; + public headers: Headers; + refreshNav: EventEmitter = new EventEmitter(); + + constructor(private BaseService: Base) { + console.log('Here in login service'); + } + + getAuthenticationKey(username, password) { + let urlSearchParams = new URLSearchParams(); + urlSearchParams.set('username', username); + urlSearchParams.set('password', password); + let body = urlSearchParams.toString(); + this.BaseService.globalHeaders.set("Content-Type", "application/x-www-form-urlencoded"); + return this.BaseService.post(environment.apiBase + '/api/users/login', body, this.BaseService.globalHeaders).map(result => { + if (result.err_msg) { + this.BaseService.logout(); + return result; + } + else { + console.log(result); + if (result.data.auth) { + localStorage.setItem('auth_token', result.data.auth); + this.BaseService.globalHeaders.set("Authorization", 'Bearer ' + result.data.auth); + return result; + } + } + }); + } + + getUserDetails(userId = 0) { + this.BaseService.globalHeaders.delete("Content-Type"); + return this.BaseService.get(environment.apiBase + '/api/users/users/' + userId, this.BaseService.globalHeaders).map(res => res); + } + + logout() { + return this.BaseService.logout(); + } + + isLoggedIn() { + return this.BaseService.isLoggedIn(); + } +} \ No newline at end of file diff --git a/code/src/app/jangular/users/users.module.ts b/code/src/app/jangular/users/users.module.ts index 4a7a407..101872b 100644 --- a/code/src/app/jangular/users/users.module.ts +++ b/code/src/app/jangular/users/users.module.ts @@ -10,6 +10,8 @@ import { UserRouterModule } from './users.router.module'; import { LoginComponent } from './login/login.component'; import { ProfileComponent } from './profile/profile.component'; import { RegistrationComponent } from './registration/registration.component'; +import { LoginService, Base } from './services/index'; +import { AlertsService } from '@jaspero/ng2-alerts'; @NgModule({ imports: [ @@ -21,7 +23,7 @@ import { RegistrationComponent } from './registration/registration.component'; // FlexLayoutModule ], declarations: [LoginComponent, ProfileComponent, RegistrationComponent], - providers : [], + providers : [LoginService, Base, AlertsService], exports : [LoginComponent, ProfileComponent, RegistrationComponent] }) export class UsersModule { } From 87b80b0e5ce42457f99a8737d48681bd79b88eea Mon Sep 17 00:00:00 2001 From: Sudhir Date: Tue, 6 Mar 2018 12:17:57 +0530 Subject: [PATCH 2/6] User component changes --- .../users/login/login.component.css | 9 +++ .../users/login/login.component.html | 35 +++++++- .../users/login/login.component.spec.ts | 24 ++++++ .../users/login/login.component.ts | 81 ++++++++++++++++--- .../users/services/base.service.ts | 69 ++++++++++++++++ .../app/clientmodule/users/services/index.ts | 3 + .../users/services/login.service.ts | 55 +++++++++++++ .../app/clientmodule/users/users.module.ts | 4 +- 8 files changed, 269 insertions(+), 11 deletions(-) create mode 100644 code/src/app/clientmodule/users/login/login.component.css create mode 100644 code/src/app/clientmodule/users/login/login.component.spec.ts create mode 100644 code/src/app/clientmodule/users/services/base.service.ts create mode 100644 code/src/app/clientmodule/users/services/index.ts create mode 100644 code/src/app/clientmodule/users/services/login.service.ts diff --git a/code/src/app/clientmodule/users/login/login.component.css b/code/src/app/clientmodule/users/login/login.component.css new file mode 100644 index 0000000..c681069 --- /dev/null +++ b/code/src/app/clientmodule/users/login/login.component.css @@ -0,0 +1,9 @@ +.example-container { + max-width: 500px; + } +.example-full-width{ + width: 100%; +} + /* .example-container > * { + width: 100%; + } */ \ No newline at end of file diff --git a/code/src/app/clientmodule/users/login/login.component.html b/code/src/app/clientmodule/users/login/login.component.html index 8a429c9..07a8dea 100644 --- a/code/src/app/clientmodule/users/login/login.component.html +++ b/code/src/app/clientmodule/users/login/login.component.html @@ -1 +1,34 @@ - \ No newline at end of file + +
+
+
+

Login

+
+
+
+
+ + + +
+ +
+ + + +
+
+ +
+
+
\ No newline at end of file diff --git a/code/src/app/clientmodule/users/login/login.component.spec.ts b/code/src/app/clientmodule/users/login/login.component.spec.ts new file mode 100644 index 0000000..fc5f46a --- /dev/null +++ b/code/src/app/clientmodule/users/login/login.component.spec.ts @@ -0,0 +1,24 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { LoginComponent } from './login.component'; + +describe('LoginComponent', () => { + let component: LoginComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ LoginComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(LoginComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should be created', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/code/src/app/clientmodule/users/login/login.component.ts b/code/src/app/clientmodule/users/login/login.component.ts index 8ecb61e..363c539 100644 --- a/code/src/app/clientmodule/users/login/login.component.ts +++ b/code/src/app/clientmodule/users/login/login.component.ts @@ -1,21 +1,84 @@ import { Component, OnInit } from '@angular/core'; -import { FormGroup, FormControl } from '@angular/forms'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { LoginService } from "../services/index"; +import { Router } from '@angular/router'; +import { AlertsService } from '@jaspero/ng2-alerts'; @Component({ - selector: 'japp-loginn', - templateUrl: './login.component.html' + selector: 'japp-login', + templateUrl: './login.component.html', + styleUrls: ['./login.component.css'] }) export class LoginComponent implements OnInit { + invalidLoginFormMessage: any; + isLoginFormValid: boolean = true; + busy1; - loginForm : FormGroup = new FormGroup({ - username : new FormControl(), - password : new FormControl() - }); + alertOptions = { + showCloseButton: true, + duration: 50000 + } - constructor( ) { } + constructor(private router: Router, + private LoginService : LoginService, + private _alert: AlertsService + ) { + console.log('In Login Component'); + } ngOnInit() { + if (this.LoginService.isLoggedIn()) { + // Get the logged in user details + console.log('Usser Logged In'); + } + else { + this.LoginService.logout(); + this.LoginService.refreshNav.emit(); + } + } + + login = new FormGroup({ + username: new FormControl(null, [Validators.required]), + password: new FormControl(null, [Validators.required]), + }); + + onSubmit({ value, valid }) { + if (valid) { + var username = value.username; + var password = value.password; + this.getLoginKey(username, password) + } } -} + getLoginKey(user, pass) { + this.busy1 = this.LoginService.getAuthenticationKey(user, pass) + .subscribe(result => { + if (result.err_msg) { + this.isLoginFormValid = false; + this.invalidLoginFormMessage = result.err_msg; + this._alert.create("error", this.invalidLoginFormMessage, this.alertOptions); + } + else { + if (result.data.auth) { + // Get the agency details and store in to local storage + localStorage.setItem('auth_token', result.data.auth); + this.LoginService.loggedIn = true; + this._alert.create("info", "You are logged in successfully redirecting....", this.alertOptions); + this.LoginService.getUserDetails(result.data.id) + .subscribe(data => { + console.log('Result of the',data); + if (result.err_msg) { + this._alert.create("error", result.err_msg, this.alertOptions); + } + else { + localStorage.setItem('authorizedUser', JSON.stringify(data.data)); + this.LoginService.refreshNav.emit(); + this.router.navigate(['/profile']); + } + }); + } + } + }); + } +} \ No newline at end of file diff --git a/code/src/app/clientmodule/users/services/base.service.ts b/code/src/app/clientmodule/users/services/base.service.ts new file mode 100644 index 0000000..911580a --- /dev/null +++ b/code/src/app/clientmodule/users/services/base.service.ts @@ -0,0 +1,69 @@ +import { Injectable, EventEmitter } from '@angular/core'; +import { Http, Headers, URLSearchParams, RequestOptionsArgs } from '@angular/http'; +import { environment } from '../../../../environments/environment'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/catch'; +import { Observable } from 'rxjs/Rx'; +import { Router } from '@angular/router'; + +@Injectable() +export class Base { + private loggedIn = false; + public globalHeaders; + refreshNav: EventEmitter = new EventEmitter(); + + constructor(public http: Http, private router: Router) { + console.log('Base Service'); + this.loggedIn = !!localStorage.getItem('auth_token'); + let authToken = localStorage.getItem('auth_token'); + this.globalHeaders = new Headers({ "Authorization": 'Bearer ' + authToken }); + } + + post(url: string, body: any, options) { + return this.http.post(url, body, { headers: options }) + .map(res => { + let response = res.json(); + if (response.err_code == '403') { + this.logout(); + this.router.navigate(['/login']); + return response; + } + else { + return response; + } + }).catch(this.handleErrors); + } + + get(url: string, options) { + return this.http.get(url, { headers: options }) + .map(res => { + let response = res.json(); + if (response.err_code == '403') { + this.logout(); + this.router.navigate(['/login']); + + return response; + } + else { + return response; + } + }).catch(this.handleErrors); + } + + logout() { + localStorage.removeItem('auth_token'); + localStorage.removeItem('authorizedUser'); + this.globalHeaders = new Headers(); + this.loggedIn = false; + } + + handleErrors(error: Response) { + return Observable.throw(error || "Server Error"); + } + + isLoggedIn() { + return this.loggedIn; + } + +} \ No newline at end of file diff --git a/code/src/app/clientmodule/users/services/index.ts b/code/src/app/clientmodule/users/services/index.ts new file mode 100644 index 0000000..ad3c713 --- /dev/null +++ b/code/src/app/clientmodule/users/services/index.ts @@ -0,0 +1,3 @@ +export * from './login.service'; +export * from './base.service'; + diff --git a/code/src/app/clientmodule/users/services/login.service.ts b/code/src/app/clientmodule/users/services/login.service.ts new file mode 100644 index 0000000..6f4870e --- /dev/null +++ b/code/src/app/clientmodule/users/services/login.service.ts @@ -0,0 +1,55 @@ +import { Injectable, EventEmitter } from '@angular/core'; +import { Http, Headers, URLSearchParams } from '@angular/http'; +import { environment } from '../../../../environments/environment'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/catch'; +import { Observable } from 'rxjs/Rx'; +import { Router } from '@angular/router'; +import { Base } from './base.service'; + +@Injectable() +export class LoginService { + public loggedIn = false; + public headers: Headers; + refreshNav: EventEmitter = new EventEmitter(); + + constructor(private BaseService: Base) { + console.log('Here in login service'); + } + + getAuthenticationKey(username, password) { + let urlSearchParams = new URLSearchParams(); + urlSearchParams.set('username', username); + urlSearchParams.set('password', password); + let body = urlSearchParams.toString(); + this.BaseService.globalHeaders.set("Content-Type", "application/x-www-form-urlencoded"); + return this.BaseService.post(environment.apiBase + '/api/users/login', body, this.BaseService.globalHeaders).map(result => { + if (result.err_msg) { + this.BaseService.logout(); + return result; + } + else { + console.log(result); + if (result.data.auth) { + localStorage.setItem('auth_token', result.data.auth); + this.BaseService.globalHeaders.set("Authorization", 'Bearer ' + result.data.auth); + return result; + } + } + }); + } + + getUserDetails(userId = 0) { + this.BaseService.globalHeaders.delete("Content-Type"); + return this.BaseService.get(environment.apiBase + '/api/users/users/' + userId, this.BaseService.globalHeaders).map(res => res); + } + + logout() { + return this.BaseService.logout(); + } + + isLoggedIn() { + return this.BaseService.isLoggedIn(); + } +} \ No newline at end of file diff --git a/code/src/app/clientmodule/users/users.module.ts b/code/src/app/clientmodule/users/users.module.ts index d602424..04e209b 100644 --- a/code/src/app/clientmodule/users/users.module.ts +++ b/code/src/app/clientmodule/users/users.module.ts @@ -8,6 +8,8 @@ import { UserRouterModule } from './users.router.module'; import { LoginComponent } from './login/login.component'; import { ProfileComponent } from './profile/profile.component'; +import { LoginService, Base } from './services/index'; +import { AlertsService } from '@jaspero/ng2-alerts'; @NgModule({ imports: [ @@ -18,7 +20,7 @@ import { ProfileComponent } from './profile/profile.component'; FlexLayoutModule ], declarations: [LoginComponent, ProfileComponent], - providers : [], + providers : [LoginService, Base, AlertsService], exports : [LoginComponent, ProfileComponent] }) export class UsersModule { } From e9d5e1955f4a483457dd0583e30c2d20f6a15399 Mon Sep 17 00:00:00 2001 From: Sudhir Date: Tue, 6 Mar 2018 12:31:57 +0530 Subject: [PATCH 3/6] User component changes, Stays in Client Module as discussed --- .../jangular/users/login/login.component.css | 9 -- .../jangular/users/login/login.component.html | 34 -------- .../users/login/login.component.spec.ts | 24 ------ .../jangular/users/login/login.component.ts | 84 ------------------- .../jangular/users/services/base.service.ts | 69 --------------- code/src/app/jangular/users/services/index.ts | 3 - .../jangular/users/services/login.service.ts | 55 ------------ code/src/app/jangular/users/users.module.ts | 10 +-- 8 files changed, 4 insertions(+), 284 deletions(-) delete mode 100644 code/src/app/jangular/users/login/login.component.css delete mode 100644 code/src/app/jangular/users/login/login.component.html delete mode 100644 code/src/app/jangular/users/login/login.component.spec.ts delete mode 100644 code/src/app/jangular/users/login/login.component.ts delete mode 100644 code/src/app/jangular/users/services/base.service.ts delete mode 100644 code/src/app/jangular/users/services/index.ts delete mode 100644 code/src/app/jangular/users/services/login.service.ts diff --git a/code/src/app/jangular/users/login/login.component.css b/code/src/app/jangular/users/login/login.component.css deleted file mode 100644 index c681069..0000000 --- a/code/src/app/jangular/users/login/login.component.css +++ /dev/null @@ -1,9 +0,0 @@ -.example-container { - max-width: 500px; - } -.example-full-width{ - width: 100%; -} - /* .example-container > * { - width: 100%; - } */ \ No newline at end of file diff --git a/code/src/app/jangular/users/login/login.component.html b/code/src/app/jangular/users/login/login.component.html deleted file mode 100644 index f761ff6..0000000 --- a/code/src/app/jangular/users/login/login.component.html +++ /dev/null @@ -1,34 +0,0 @@ - -
-
-
-

Login

-
-
-
-
- - - -
- -
- - - -
-
- -
-
-
\ No newline at end of file diff --git a/code/src/app/jangular/users/login/login.component.spec.ts b/code/src/app/jangular/users/login/login.component.spec.ts deleted file mode 100644 index fc5f46a..0000000 --- a/code/src/app/jangular/users/login/login.component.spec.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { LoginComponent } from './login.component'; - -describe('LoginComponent', () => { - let component: LoginComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ LoginComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(LoginComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should be created', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/code/src/app/jangular/users/login/login.component.ts b/code/src/app/jangular/users/login/login.component.ts deleted file mode 100644 index 363c539..0000000 --- a/code/src/app/jangular/users/login/login.component.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { FormControl, FormGroup, Validators } from '@angular/forms'; -import { LoginService } from "../services/index"; -import { Router } from '@angular/router'; -import { AlertsService } from '@jaspero/ng2-alerts'; - - -@Component({ - selector: 'japp-login', - templateUrl: './login.component.html', - styleUrls: ['./login.component.css'] -}) -export class LoginComponent implements OnInit { - invalidLoginFormMessage: any; - isLoginFormValid: boolean = true; - busy1; - - alertOptions = { - showCloseButton: true, - duration: 50000 - } - - constructor(private router: Router, - private LoginService : LoginService, - private _alert: AlertsService - ) { - console.log('In Login Component'); - } - - ngOnInit() { - if (this.LoginService.isLoggedIn()) { - // Get the logged in user details - console.log('Usser Logged In'); - } - else { - this.LoginService.logout(); - this.LoginService.refreshNav.emit(); - } - } - - login = new FormGroup({ - username: new FormControl(null, [Validators.required]), - password: new FormControl(null, [Validators.required]), - }); - - onSubmit({ value, valid }) { - if (valid) { - var username = value.username; - var password = value.password; - this.getLoginKey(username, password) - } - } - - getLoginKey(user, pass) { - this.busy1 = this.LoginService.getAuthenticationKey(user, pass) - .subscribe(result => { - if (result.err_msg) { - this.isLoginFormValid = false; - this.invalidLoginFormMessage = result.err_msg; - this._alert.create("error", this.invalidLoginFormMessage, this.alertOptions); - } - else { - if (result.data.auth) { - // Get the agency details and store in to local storage - localStorage.setItem('auth_token', result.data.auth); - this.LoginService.loggedIn = true; - this._alert.create("info", "You are logged in successfully redirecting....", this.alertOptions); - this.LoginService.getUserDetails(result.data.id) - .subscribe(data => { - console.log('Result of the',data); - if (result.err_msg) { - this._alert.create("error", result.err_msg, this.alertOptions); - } - else { - localStorage.setItem('authorizedUser', JSON.stringify(data.data)); - this.LoginService.refreshNav.emit(); - this.router.navigate(['/profile']); - } - }); - } - } - }); - } -} \ No newline at end of file diff --git a/code/src/app/jangular/users/services/base.service.ts b/code/src/app/jangular/users/services/base.service.ts deleted file mode 100644 index 911580a..0000000 --- a/code/src/app/jangular/users/services/base.service.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { Injectable, EventEmitter } from '@angular/core'; -import { Http, Headers, URLSearchParams, RequestOptionsArgs } from '@angular/http'; -import { environment } from '../../../../environments/environment'; -import 'rxjs/add/operator/map'; -import 'rxjs/add/operator/do'; -import 'rxjs/add/operator/catch'; -import { Observable } from 'rxjs/Rx'; -import { Router } from '@angular/router'; - -@Injectable() -export class Base { - private loggedIn = false; - public globalHeaders; - refreshNav: EventEmitter = new EventEmitter(); - - constructor(public http: Http, private router: Router) { - console.log('Base Service'); - this.loggedIn = !!localStorage.getItem('auth_token'); - let authToken = localStorage.getItem('auth_token'); - this.globalHeaders = new Headers({ "Authorization": 'Bearer ' + authToken }); - } - - post(url: string, body: any, options) { - return this.http.post(url, body, { headers: options }) - .map(res => { - let response = res.json(); - if (response.err_code == '403') { - this.logout(); - this.router.navigate(['/login']); - return response; - } - else { - return response; - } - }).catch(this.handleErrors); - } - - get(url: string, options) { - return this.http.get(url, { headers: options }) - .map(res => { - let response = res.json(); - if (response.err_code == '403') { - this.logout(); - this.router.navigate(['/login']); - - return response; - } - else { - return response; - } - }).catch(this.handleErrors); - } - - logout() { - localStorage.removeItem('auth_token'); - localStorage.removeItem('authorizedUser'); - this.globalHeaders = new Headers(); - this.loggedIn = false; - } - - handleErrors(error: Response) { - return Observable.throw(error || "Server Error"); - } - - isLoggedIn() { - return this.loggedIn; - } - -} \ No newline at end of file diff --git a/code/src/app/jangular/users/services/index.ts b/code/src/app/jangular/users/services/index.ts deleted file mode 100644 index ad3c713..0000000 --- a/code/src/app/jangular/users/services/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './login.service'; -export * from './base.service'; - diff --git a/code/src/app/jangular/users/services/login.service.ts b/code/src/app/jangular/users/services/login.service.ts deleted file mode 100644 index 6f4870e..0000000 --- a/code/src/app/jangular/users/services/login.service.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { Injectable, EventEmitter } from '@angular/core'; -import { Http, Headers, URLSearchParams } from '@angular/http'; -import { environment } from '../../../../environments/environment'; -import 'rxjs/add/operator/map'; -import 'rxjs/add/operator/do'; -import 'rxjs/add/operator/catch'; -import { Observable } from 'rxjs/Rx'; -import { Router } from '@angular/router'; -import { Base } from './base.service'; - -@Injectable() -export class LoginService { - public loggedIn = false; - public headers: Headers; - refreshNav: EventEmitter = new EventEmitter(); - - constructor(private BaseService: Base) { - console.log('Here in login service'); - } - - getAuthenticationKey(username, password) { - let urlSearchParams = new URLSearchParams(); - urlSearchParams.set('username', username); - urlSearchParams.set('password', password); - let body = urlSearchParams.toString(); - this.BaseService.globalHeaders.set("Content-Type", "application/x-www-form-urlencoded"); - return this.BaseService.post(environment.apiBase + '/api/users/login', body, this.BaseService.globalHeaders).map(result => { - if (result.err_msg) { - this.BaseService.logout(); - return result; - } - else { - console.log(result); - if (result.data.auth) { - localStorage.setItem('auth_token', result.data.auth); - this.BaseService.globalHeaders.set("Authorization", 'Bearer ' + result.data.auth); - return result; - } - } - }); - } - - getUserDetails(userId = 0) { - this.BaseService.globalHeaders.delete("Content-Type"); - return this.BaseService.get(environment.apiBase + '/api/users/users/' + userId, this.BaseService.globalHeaders).map(res => res); - } - - logout() { - return this.BaseService.logout(); - } - - isLoggedIn() { - return this.BaseService.isLoggedIn(); - } -} \ No newline at end of file diff --git a/code/src/app/jangular/users/users.module.ts b/code/src/app/jangular/users/users.module.ts index 101872b..ffbffb6 100644 --- a/code/src/app/jangular/users/users.module.ts +++ b/code/src/app/jangular/users/users.module.ts @@ -7,11 +7,9 @@ import { HttpClientModule } from '@angular/common/http'; import { JangularMaterial } from '../jangular.material.module'; import { UserRouterModule } from './users.router.module'; -import { LoginComponent } from './login/login.component'; import { ProfileComponent } from './profile/profile.component'; import { RegistrationComponent } from './registration/registration.component'; -import { LoginService, Base } from './services/index'; -import { AlertsService } from '@jaspero/ng2-alerts'; + @NgModule({ imports: [ @@ -22,8 +20,8 @@ import { AlertsService } from '@jaspero/ng2-alerts'; JangularMaterial // FlexLayoutModule ], - declarations: [LoginComponent, ProfileComponent, RegistrationComponent], - providers : [LoginService, Base, AlertsService], - exports : [LoginComponent, ProfileComponent, RegistrationComponent] + declarations: [ProfileComponent, RegistrationComponent], + providers : [], + exports : [ ProfileComponent, RegistrationComponent] }) export class UsersModule { } From 2f900e687d1970f59be94f67c055b6db50059a36 Mon Sep 17 00:00:00 2001 From: Sudhir Date: Wed, 7 Mar 2018 15:26:45 +0530 Subject: [PATCH 4/6] Registration form and adding to joomla user --- code/src/app/clientmodule/client.module.ts | 3 - .../users/login/login.component.html | 16 +++-- .../users/login/login.component.ts | 13 ++-- .../users/profile/profile.component.html | 6 +- .../users/profile/profile.component.ts | 11 +++- .../users/register/register.component.html | 66 +++++++++++++++++++ .../users/register/register.component.ts | 60 +++++++++++++++++ .../users/services/base.service.ts | 9 ++- .../app/clientmodule/users/services/index.ts | 2 +- .../users/services/login.service.ts | 1 - .../users/services/register.service.ts | 43 ++++++++++++ .../app/clientmodule/users/users.module.ts | 7 +- .../clientmodule/users/users.router.module.ts | 4 +- 13 files changed, 215 insertions(+), 26 deletions(-) create mode 100644 code/src/app/clientmodule/users/register/register.component.html create mode 100644 code/src/app/clientmodule/users/register/register.component.ts create mode 100644 code/src/app/clientmodule/users/services/register.service.ts diff --git a/code/src/app/clientmodule/client.module.ts b/code/src/app/clientmodule/client.module.ts index a9fff1b..0429151 100644 --- a/code/src/app/clientmodule/client.module.ts +++ b/code/src/app/clientmodule/client.module.ts @@ -1,8 +1,5 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; - - - import { UsersModule } from './users/users.module'; import { ContentModule } from './content/content.module'; diff --git a/code/src/app/clientmodule/users/login/login.component.html b/code/src/app/clientmodule/users/login/login.component.html index 07a8dea..17c2bc8 100644 --- a/code/src/app/clientmodule/users/login/login.component.html +++ b/code/src/app/clientmodule/users/login/login.component.html @@ -1,15 +1,15 @@ +
-

Login

+

Login

- +
-
+ +
+ + + Register
-
\ No newline at end of file +
+
\ No newline at end of file diff --git a/code/src/app/clientmodule/users/login/login.component.ts b/code/src/app/clientmodule/users/login/login.component.ts index 363c539..3e41ac9 100644 --- a/code/src/app/clientmodule/users/login/login.component.ts +++ b/code/src/app/clientmodule/users/login/login.component.ts @@ -28,14 +28,14 @@ export class LoginComponent implements OnInit { } ngOnInit() { - if (this.LoginService.isLoggedIn()) { + if (this.LoginService.isLoggedIn()) { // Get the logged in user details - console.log('Usser Logged In'); + this.router.navigate(['/profile']); } else { this.LoginService.logout(); this.LoginService.refreshNav.emit(); - } + } } login = new FormGroup({ @@ -63,13 +63,12 @@ export class LoginComponent implements OnInit { if (result.data.auth) { // Get the agency details and store in to local storage localStorage.setItem('auth_token', result.data.auth); - this.LoginService.loggedIn = true; this._alert.create("info", "You are logged in successfully redirecting....", this.alertOptions); + this.LoginService.loggedIn = true; this.LoginService.getUserDetails(result.data.id) .subscribe(data => { - console.log('Result of the',data); - if (result.err_msg) { - this._alert.create("error", result.err_msg, this.alertOptions); + if (data.err_msg) { + this._alert.create("error", data.err_msg, this.alertOptions); } else { localStorage.setItem('authorizedUser', JSON.stringify(data.data)); diff --git a/code/src/app/clientmodule/users/profile/profile.component.html b/code/src/app/clientmodule/users/profile/profile.component.html index be88b13..66ae4a9 100644 --- a/code/src/app/clientmodule/users/profile/profile.component.html +++ b/code/src/app/clientmodule/users/profile/profile.component.html @@ -1 +1,5 @@ -

I am inside profile {{ userid }}

\ No newline at end of file +
+

Hi {{currentUser.name}}!

+

You're logged in

+

Logout

+
\ No newline at end of file diff --git a/code/src/app/clientmodule/users/profile/profile.component.ts b/code/src/app/clientmodule/users/profile/profile.component.ts index 87fb5d3..647179e 100644 --- a/code/src/app/clientmodule/users/profile/profile.component.ts +++ b/code/src/app/clientmodule/users/profile/profile.component.ts @@ -1,5 +1,6 @@ import { Component } from '@angular/core'; - +import { Router } from '@angular/router'; +import { LoginService } from "../services/index"; @Component({ selector: 'japp-profile', templateUrl: './profile.component.html', @@ -7,5 +8,11 @@ import { Component } from '@angular/core'; }) export class ProfileComponent { - + currentUser; + + constructor(private LoginService: LoginService, private router: Router) { + this.currentUser = JSON.parse(localStorage.getItem('authorizedUser')); + } + ngOnInit() { + } } \ No newline at end of file diff --git a/code/src/app/clientmodule/users/register/register.component.html b/code/src/app/clientmodule/users/register/register.component.html new file mode 100644 index 0000000..6ed9633 --- /dev/null +++ b/code/src/app/clientmodule/users/register/register.component.html @@ -0,0 +1,66 @@ + +
+
+
+

Registration Page

+
+
+
+
+ + + +
+
+ + + +
+
+ + + +
+ +
+ + + +
+ +
+ + + +
+ + +
+ + + Login +
+
+
\ No newline at end of file diff --git a/code/src/app/clientmodule/users/register/register.component.ts b/code/src/app/clientmodule/users/register/register.component.ts new file mode 100644 index 0000000..4514be6 --- /dev/null +++ b/code/src/app/clientmodule/users/register/register.component.ts @@ -0,0 +1,60 @@ +import { Component, OnInit } from '@angular/core'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { Router } from '@angular/router'; +import { Base,RegisterService } from '../services/index'; +import { AlertsService } from '@jaspero/ng2-alerts'; + +@Component({ + templateUrl: './register.component.html' +}) +export class RegisterComponent implements OnInit { + + alertOptions = { + showCloseButton: true, + duration: 50000 + } + + constructor(private route:Router, + private Base : Base, + private RegisterService :RegisterService, + private _alert : AlertsService + ) { + console.log('In Login Component'); + } + + register = new FormGroup({ + firstname: new FormControl(null, [Validators.required]), + lastname: new FormControl(null, [Validators.required]), + email: new FormControl(null, [Validators.required]), + password: new FormControl(null, [Validators.required]), + username: new FormControl(null, [Validators.required]), + }); + + ngOnInit() { + } + + onSubmit({ value, valid }) { + if (valid) { + let data = []; + data['name'] = value.firstname+' '+value.lastname; + data['email'] = value.email; + data['username'] = value.username; + data['password'] = value.password; + this.createUser(data); + } + } + + createUser(data){ + console.log('Posted Data',data); + this.RegisterService.createUser(data).subscribe(result => { + console.log('User Created'); + if (result.err_msg) { + //this.invalidLoginFormMessage = result.err_msg; + this._alert.create("error", result.err_msg, this.alertOptions); + } + else{ + console.log('Registered User Successfully'); + } + }); + } +} \ No newline at end of file diff --git a/code/src/app/clientmodule/users/services/base.service.ts b/code/src/app/clientmodule/users/services/base.service.ts index 911580a..54af7a6 100644 --- a/code/src/app/clientmodule/users/services/base.service.ts +++ b/code/src/app/clientmodule/users/services/base.service.ts @@ -14,13 +14,18 @@ export class Base { refreshNav: EventEmitter = new EventEmitter(); constructor(public http: Http, private router: Router) { - console.log('Base Service'); this.loggedIn = !!localStorage.getItem('auth_token'); let authToken = localStorage.getItem('auth_token'); this.globalHeaders = new Headers({ "Authorization": 'Bearer ' + authToken }); } post(url: string, body: any, options) { + console.log('Base Service Post'); + console.log('Base Service Post URL',url); + console.log('Base Service Post BODY',body); + console.log('Base Service Post OPTIONS',options); + console.log('HTTP'); + console.dir(this.http); return this.http.post(url, body, { headers: options }) .map(res => { let response = res.json(); @@ -42,7 +47,6 @@ export class Base { if (response.err_code == '403') { this.logout(); this.router.navigate(['/login']); - return response; } else { @@ -56,6 +60,7 @@ export class Base { localStorage.removeItem('authorizedUser'); this.globalHeaders = new Headers(); this.loggedIn = false; + this.router.navigate(['/login']); } handleErrors(error: Response) { diff --git a/code/src/app/clientmodule/users/services/index.ts b/code/src/app/clientmodule/users/services/index.ts index ad3c713..8274310 100644 --- a/code/src/app/clientmodule/users/services/index.ts +++ b/code/src/app/clientmodule/users/services/index.ts @@ -1,3 +1,3 @@ export * from './login.service'; export * from './base.service'; - +export * from './register.service'; diff --git a/code/src/app/clientmodule/users/services/login.service.ts b/code/src/app/clientmodule/users/services/login.service.ts index 6f4870e..a198f4f 100644 --- a/code/src/app/clientmodule/users/services/login.service.ts +++ b/code/src/app/clientmodule/users/services/login.service.ts @@ -30,7 +30,6 @@ export class LoginService { return result; } else { - console.log(result); if (result.data.auth) { localStorage.setItem('auth_token', result.data.auth); this.BaseService.globalHeaders.set("Authorization", 'Bearer ' + result.data.auth); diff --git a/code/src/app/clientmodule/users/services/register.service.ts b/code/src/app/clientmodule/users/services/register.service.ts new file mode 100644 index 0000000..36c8a90 --- /dev/null +++ b/code/src/app/clientmodule/users/services/register.service.ts @@ -0,0 +1,43 @@ +import { Injectable, EventEmitter } from '@angular/core'; +import { Http, Headers, URLSearchParams } from '@angular/http'; +import { environment } from '../../../../environments/environment'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/catch'; +import { Observable } from 'rxjs/Rx'; +import { Router } from '@angular/router'; +import { Base } from "../services/index"; + +@Injectable() +export class RegisterService { + public headers: Headers; + refreshNav: EventEmitter = new EventEmitter(); + + constructor(private BaseService: Base) { + console.log('Here in login service'); + } + + createUser(data) { + console.log('In Register Service', data); + let urlSearchParams = new URLSearchParams(); + urlSearchParams.set('username', data['username']); + urlSearchParams.set('name', data['name']); + urlSearchParams.set('email', data['email']); + urlSearchParams.set('password', data['password']); + let body = urlSearchParams.toString(); + this.BaseService.globalHeaders.set("Content-Type", "application/x-www-form-urlencoded"); + return this.BaseService.post(environment.apiBase + '/api/users/users', body, this.BaseService.globalHeaders).map(result => { + if (result.err_msg) { + console.log('Error Here',result); + //this.BaseService.logout(); + return result; + } + else { + if (result) { + console.log('Success Here in',result); + return result; + } + } + }); + } +} \ No newline at end of file diff --git a/code/src/app/clientmodule/users/users.module.ts b/code/src/app/clientmodule/users/users.module.ts index 04e209b..ccc1ca4 100644 --- a/code/src/app/clientmodule/users/users.module.ts +++ b/code/src/app/clientmodule/users/users.module.ts @@ -8,7 +8,8 @@ import { UserRouterModule } from './users.router.module'; import { LoginComponent } from './login/login.component'; import { ProfileComponent } from './profile/profile.component'; -import { LoginService, Base } from './services/index'; +import { RegisterComponent } from './register/register.component'; +import { LoginService, Base, RegisterService } from './services/index'; import { AlertsService } from '@jaspero/ng2-alerts'; @NgModule({ @@ -19,8 +20,8 @@ import { AlertsService } from '@jaspero/ng2-alerts'; HttpClientModule, FlexLayoutModule ], - declarations: [LoginComponent, ProfileComponent], - providers : [LoginService, Base, AlertsService], + declarations: [LoginComponent, ProfileComponent, RegisterComponent], + providers : [LoginService, Base, AlertsService, RegisterService], exports : [LoginComponent, ProfileComponent] }) export class UsersModule { } diff --git a/code/src/app/clientmodule/users/users.router.module.ts b/code/src/app/clientmodule/users/users.router.module.ts index c707dd7..b04c07c 100644 --- a/code/src/app/clientmodule/users/users.router.module.ts +++ b/code/src/app/clientmodule/users/users.router.module.ts @@ -3,10 +3,12 @@ import { RouterModule, Routes } from '@angular/router'; import { LoginComponent } from './login/login.component'; import { ProfileComponent } from './profile/profile.component'; +import { RegisterComponent } from './register/register.component'; const appRoutes: Routes = [ { path: 'login', component: LoginComponent }, - { path: 'profile', component: ProfileComponent } + { path: 'profile', component: ProfileComponent }, + { path: 'register', component: RegisterComponent } ] @NgModule({ From 9c7c6f4f475b00ca8997a8289e9f1a2194a84574 Mon Sep 17 00:00:00 2001 From: Sudhir Date: Wed, 21 Mar 2018 11:05:08 +0530 Subject: [PATCH 5/6] Removed alert package --- code/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/code/package.json b/code/package.json index 2f472df..3b5bcd2 100644 --- a/code/package.json +++ b/code/package.json @@ -30,7 +30,6 @@ "bootstrap": "^3.3.7", "core-js": "^2.4.1", "hammerjs": "^2.0.8", - "ng2-alert": "0.0.0", "rxjs": "^5.4.2", "zone.js": "^0.8.14" }, From 84c8769554f2adb0e4fb22ebb5d1f8a22057d264 Mon Sep 17 00:00:00 2001 From: Sudhir Date: Wed, 21 Mar 2018 11:07:29 +0530 Subject: [PATCH 6/6] Revert the change of ** for any route --- code/src/app/clientmodule/content/content.router.module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/src/app/clientmodule/content/content.router.module.ts b/code/src/app/clientmodule/content/content.router.module.ts index 7ece82b..ff1abad 100644 --- a/code/src/app/clientmodule/content/content.router.module.ts +++ b/code/src/app/clientmodule/content/content.router.module.ts @@ -7,7 +7,7 @@ import { ArticleComponent } from './article/article.component'; const appRoutes: Routes = [ { path: '', component: ArticlesComponent }, - { path: '**', component: ArticleComponent } + { path: 'article/:article-alias', component: ArticleComponent } ]; @NgModule({