keygen.component.ts 1021 Bytes
Newer Older
Chris Hines's avatar
Chris Hines committed
1
import { Component, OnInit, AfterViewInit } from '@angular/core';
Chris Hines's avatar
Chris Hines committed
2
import { Router, NavigationStart } from '@angular/router';
Chris Hines's avatar
Chris Hines committed
3
import { AuthorisationService } from '../authorisation.service';
Chris Hines's avatar
Chris Hines committed
4
5
6
7
8
9
10
11
12




@Component({
  selector: 'app-keygen',
  templateUrl: './keygen.component.html',
  styleUrls: ['./keygen.component.css']
})
Chris Hines's avatar
Chris Hines committed
13
export class KeygenComponent implements OnInit, AfterViewInit {
Chris Hines's avatar
Chris Hines committed
14

Chris Hines's avatar
Chris Hines committed
15
  constructor(private router: Router, private authService: AuthorisationService) { }
Chris Hines's avatar
Chris Hines committed
16
17

  ngOnInit() {
Chris Hines's avatar
Chris Hines committed
18
19
20
    // This component is the callback form OAuth flows.
    // We hold here while the authService extract the token from the URI and generates keys
    // Once the keys are generated we can navigate away from this callback component
Chris Hines's avatar
Chris Hines committed
21
    this.authService.readyToNavigate.subscribe(readyToNavigate => this.navigate(readyToNavigate));
Chris Hines's avatar
Chris Hines committed
22
23
24
  }

  ngAfterViewInit() {
Chris Hines's avatar
Chris Hines committed
25
    this.authService.getCert();
Chris Hines's avatar
Chris Hines committed
26
27
28
29
30
31
32
33
34
  }

  navigate(readyToNavigate: [Boolean,string]) {
    if (readyToNavigate[0]) {
      this.router.navigate([readyToNavigate[1]]);
    }
  }

}