How to run code after success authorization

I build the login like in the quickstart tutorial: https://developer.okta.com/quickstart/#/angular/nodejs/express

But I couldn’t figure out how to execute code after successful authentication. After redirecting, bugs may occur later, as the target page may change later. So I have to enter right after the implicit callback.

Solved. I created my own callback component and added it to the route.

Callback Component:

@Component({
  template: ''
})
export class AuthenticationCallbackComponent {

  constructor(private oktaAuth: OktaAuthService) {
    oktaAuth.handleAuthentication().then( () => {
      this.run();
    });
  }

  private run() {
    // Run some code after auth
  }
}

Route:

{
  path: IMPLICIT_TOKEN_CALLBACK,
  component: AuthenticationCallbackComponent,
}