aboutsummaryrefslogtreecommitdiff
path: root/src/app/authorization-request/authorization-request.component.ts
blob: bba64130a269d44e84de595a140977052283b9df (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { OpenIdService } from '../open-id.service';
import { GnsService } from '../gns.service';
import { LanguageService } from '../language.service';

/* For Chrome browsers */
declare var chrome: any;

@Component({
  selector: 'app-authorization-request',
  templateUrl: './authorization-request.component.html',
  styleUrls: ['./authorization-request.component.css']
})
export class AuthorizationRequestComponent implements OnInit {

  browser: typeof browser;

  constructor(private oidcService: OpenIdService,
              private gnsService: GnsService,
              private languageService: LanguageService,
              private router: Router) { }

  ngOnInit() {
    this.retryVerify();
  }

  getRequestedStandardScopesWithDescription() {
    return this.oidcService.getRequestedStandardScopesWithDescription();
  }

  getRequestedNonStandardClaims() {
    return this.oidcService.getRequestedNonStandardClaims();
  }

  isClientVerified() {
    return this.oidcService.isClientVerified();
  }

  cancelRequest() {
    this.oidcService.cancelAuthorization().subscribe(() => {
      console.log(this.getMessage("authorization_request_ts@requestCancelled"));
      this.router.navigate(['/']);
      //Manually reset this component
    });
  }

  retryVerify() {
    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.oidcService.setClientName(records[i].value);
        this.router.navigate(['/']);
        return;
      }
    }, err => {
      console.log(err);
    });
  }

  //Internationalization
  getMessage(key, sub?){
    return this.languageService.getMessage(key, sub);
  }
}