From 06a374032147df1112b221d70d2acde92e65ee11 Mon Sep 17 00:00:00 2001 From: "Schanzenbach, Martin" Date: Tue, 10 Dec 2019 20:08:57 +0100 Subject: more refactoring --- src/app/app-routing.module.ts | 8 +-- src/app/app.module.ts | 4 +- .../authorization-request.component.css | 0 .../authorization-request.component.html | 40 +++++++++++++++ .../authorization-request.component.ts | 59 ++++++++++++++++++++++ src/app/identity-list/identity-list.component.html | 45 ----------------- src/app/identity-list/identity-list.component.ts | 57 ++------------------- src/styles.scss | 2 + 8 files changed, 112 insertions(+), 103 deletions(-) create mode 100644 src/app/authorization-request/authorization-request.component.css create mode 100644 src/app/authorization-request/authorization-request.component.html create mode 100644 src/app/authorization-request/authorization-request.component.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 30f732c..9019e84 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -3,17 +3,19 @@ import { RouterModule, Routes } from '@angular/router'; import { IdentityListComponent } from './identity-list/identity-list.component'; import { NewIdentityComponent } from './new-identity/new-identity.component'; import { EditIdentityComponent } from './edit-identity/edit-identity.component'; +import { AuthorizationRequestComponent } from './authorization-request/authorization-request.component'; const routes: Routes = [ - { path: 'index.html', component: IdentityListComponent }, + { path: '', component: IdentityListComponent }, // { path: 'identities', component: IdentityListComponent }, - { path: '', redirectTo: '/index.html', pathMatch: 'full' }, + //{ path: '', redirectTo: '/index.html', pathMatch: 'full' }, { path: 'new-identity', component: NewIdentityComponent }, { path: 'edit-identity/:id', component: EditIdentityComponent }, + { path: 'authorization-request', component: AuthorizationRequestComponent } ]; @NgModule({ - imports: [RouterModule.forRoot(routes, { useHash: false })], + imports: [RouterModule.forRoot(routes, { useHash: true })], exports: [RouterModule] }) export class AppRoutingModule { } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 77d4efb..d1c8b7a 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -17,6 +17,7 @@ import { SearchPipe } from './search.pipe'; import { OpenIdService } from './open-id.service'; import { NewIdentityComponent } from './new-identity/new-identity.component'; import { EditIdentityComponent } from './edit-identity/edit-identity.component'; +import { AuthorizationRequestComponent } from './authorization-request/authorization-request.component'; @NgModule({ declarations: [ @@ -25,7 +26,8 @@ import { EditIdentityComponent } from './edit-identity/edit-identity.component'; ModalComponent, SearchPipe, NewIdentityComponent, - EditIdentityComponent + EditIdentityComponent, + AuthorizationRequestComponent ], imports: [ BrowserModule, diff --git a/src/app/authorization-request/authorization-request.component.css b/src/app/authorization-request/authorization-request.component.css new file mode 100644 index 0000000..e69de29 diff --git a/src/app/authorization-request/authorization-request.component.html b/src/app/authorization-request/authorization-request.component.html new file mode 100644 index 0000000..e323603 --- /dev/null +++ b/src/app/authorization-request/authorization-request.component.html @@ -0,0 +1,40 @@ +
+ + + Verifying request, please stand by... + + + + Authorization Request + + + Authorization failed. + +
+
+
"{{ clientName }}" + asks you to share personal information.
+ Choose an identity to let it access the following information: +
+ +
+ + +
+
+ +
+
+ +
+ diff --git a/src/app/authorization-request/authorization-request.component.ts b/src/app/authorization-request/authorization-request.component.ts new file mode 100644 index 0000000..96353f1 --- /dev/null +++ b/src/app/authorization-request/authorization-request.component.ts @@ -0,0 +1,59 @@ +import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; +import { OpenIdService } from '../open-id.service'; +import { GnsService } from '../gns.service'; + +@Component({ + selector: 'app-authorization-request', + templateUrl: './authorization-request.component.html', + styleUrls: ['./authorization-request.component.css'] +}) +export class AuthorizationRequestComponent implements OnInit { + clientNameFound: Boolean; + clientName: String; + + constructor(private oidcService: OpenIdService, + private gnsService: GnsService, + private router: Router) { } + + ngOnInit() { + this.clientNameFound = false; + this.clientName = '-'; + this.getClientName(); + } + + getClientName() { + this.clientNameFound = undefined; + this.clientName = this.oidcService.getClientId(); + if (!this.oidcService.inOpenIdFlow()) { + return; + } + this.gnsService.getClientName(this.oidcService.getClientId()) + .subscribe(record => { + const records = record.data; + console.log(records); + for (let i = 0; i < records.length; i++) { + if (records[i].record_type !== 'RECLAIM_OIDC_CLIENT') { + continue; + } + this.clientName = records[i].value; + this.clientNameFound = true; + return; + } + this.clientNameFound = false; + }, err => { + console.log(err); + this.clientNameFound = false; + }); + } + + cancelRequest() { + this.oidcService.cancelAuthorization().subscribe(() => { + console.log('Request cancelled'); + this.router.navigate(['/']); + //Manually reset this component + }); + } + + +} diff --git a/src/app/identity-list/identity-list.component.html b/src/app/identity-list/identity-list.component.html index bca97b5..7edb1e8 100644 --- a/src/app/identity-list/identity-list.component.html +++ b/src/app/identity-list/identity-list.component.html @@ -1,48 +1,3 @@ - - -
- -
- - - Verifying request, please stand by... - - - - Authorization Request - - - Authorization failed. - -
-
-
"{{ clientName }}" - asks you to share personal information.
- Choose an identity to let it access the following information: -
- -
- - -
-
- -
-
- -
-
- diff --git a/src/app/identity-list/identity-list.component.ts b/src/app/identity-list/identity-list.component.ts index 17f1da4..b4971a3 100644 --- a/src/app/identity-list/identity-list.component.ts +++ b/src/app/identity-list/identity-list.component.ts @@ -55,8 +55,10 @@ export class IdentityListComponent implements OnInit { this.modalOpened = false; if (!this.oidcService.inOpenIdFlow()) { this.oidcService.parseRouteParams(this.route.snapshot.queryParams); + if (this.oidcService.inOpenIdFlow()) { + this.router.navigate(['/authorization-request']); + } } - this.getClientName(); this.identityNameMapper = {}; this.updateIdentities(); this.errorInfos = []; @@ -68,47 +70,6 @@ export class IdentityListComponent implements OnInit { hideConfirmDelete() { this.showConfirmDelete = null; } - getClientName() { - this.clientNameFound = undefined; - this.clientName = this.oidcService.getClientId(); - if (!this.oidcService.inOpenIdFlow()) { - return; - } - this.gnsService.getClientName(this.oidcService.getClientId()) - .subscribe(record => { - const records = record.data; - console.log(records); - for (let i = 0; i < records.length; i++) { - if (records[i].record_type !== 'RECLAIM_OIDC_CLIENT') { - continue; - } - this.clientName = records[i].value; - this.clientNameFound = true; - return; - } - this.clientNameFound = false; - }, err => { - console.log(err); - this.clientNameFound = false; - }); - } - - intToRGB(i) { - i = this.hashCode(i); - const c = (i & 0x00FFFFFF).toString(16).toUpperCase(); - - return '#' + - '00000'.substring(0, 6 - c.length) + c; - } - - hashCode(str) { - let hash = 0; - for (let i = 0; i < str.length; i++) { - hash = str.charCodeAt(i) + ((hash << 5) - hash); - } - return hash; - } - getMissingAttributes(identity) { const scopes = this.getScopes(); let i; @@ -164,18 +125,6 @@ export class IdentityListComponent implements OnInit { }); } - cancelRequest() { - this.closeModal('OpenIdInfo'); - this.modalOpened = false; - this.oidcService.cancelAuthorization().subscribe(() => { - console.log('Request cancelled'); - this.requestedAttributes = {}; - this.missingAttributes = {}; - this.router.navigate(['/']); - //Manually reset this component - }); - } - loginIdentity(identity) { this.oidcService.login(identity).subscribe(() => { console.log('Successfully logged in'); diff --git a/src/styles.scss b/src/styles.scss index d76e90c..a1c43dd 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -113,6 +113,8 @@ div.card-avatar-id { .card-avatar .btn-primary:hover { background-image: none; color: #444; + border: none; + box-shadow: none; background-color: #eee; } -- cgit v1.2.3