Nebular Oauth2 Google Войти не перенаправить - PullRequest
0 голосов
/ 13 марта 2020

я использую nebular oauth2 google, например, логин

в моем auth.module.ts

NbAuthModule.forRoot({
  strategies: [
    NbOAuth2AuthStrategy.setup({
      name: 'google',
      clientId: '219027435285-822fstg8ddquhag9bcu94v5vutclng42.apps.googleusercontent.com',
      clientSecret: '',
      authorize: {
        endpoint: 'https://accounts.google.com/o/oauth2/v2/auth',
        responseType: NbOAuth2ResponseType.TOKEN,
        scope: 'https://www.googleapis.com/auth/userinfo.profile',
        redirectUri: 'https://kewirus-v1.web.app/auth/callback',
      },
    }),
  ],
  forms: {},
}),

в моем компоненте входа в систему

  userPass:any;
  userMail:any;
  token:any;
  constructor(service: NbAuthService,@Inject(NB_AUTH_OPTIONS) options: {},cd: ChangeDetectorRef, router: Router) {
    super(service,options,cd, router);
  }

  alive = true;

  login() {
    this.service.authenticate('google')
      .pipe(takeWhile(() => this.alive))
      .subscribe((authResult: NbAuthResult) => {
        console.log();

      });
  }

  ngOnDestroy(): void {
    this.alive = false;
  }

и в моем callbackcomponent

  private destroy$ = new Subject<void>();

  constructor(private authService: NbAuthService, private router: Router) {
    this.authService.authenticate('google')
      .pipe(takeUntil(this.destroy$))
      .subscribe((authResult: NbAuthResult) => {
        if (authResult.isSuccess()) {
          this.router.navigateByUrl('../pages/dashboard');
        }
      });
  }

  ngOnDestroy(): void {
    this.destroy$.next();
    this.destroy$.complete();
  }

он должен перенаправить на страницу панели мониторинга, но перенаправить обратно на страницу входа, а не на страницу панели мониторинга. что я сделал не так?

...