Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: start tokenService on login redirect #48

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 3.2.1

### Bug Fixes

[#48](https://github.com/okta/okta-angular/pull/48) fix: start tokenService on login redirect

# 3.2.0

### Other
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@okta/okta-angular",
"private": true,
"version": "3.2.0",
"version": "3.2.1",
"description": "Angular support for Okta",
"main": "./dist/bundles/okta-angular.umd.js",
"module": "./dist/fesm5/okta-angular.js",
Expand Down
6 changes: 4 additions & 2 deletions src/okta/services/okta.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ export class OktaAuthService extends OktaAuth implements OnDestroy {
});
if (!this.token.isLoginRedirect()) {
// Trigger an initial change event to make sure authState is latest
// Also starts the token auto-renew service
this.start();
this.authStateManager.updateAuthState();
}

// Start the token auto-renew service
this.tokenManager.start();
}

ngOnDestroy(): void {
Expand Down
7 changes: 7 additions & 0 deletions test/spec/service.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { TestBed } from "@angular/core/testing";
import { RouterTestingModule } from '@angular/router/testing';
import { Router } from '@angular/router';
import * as OktaAuth from '@okta/okta-auth-js';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const PACKAGE_JSON = require("../../package.json");
Expand Down Expand Up @@ -34,6 +35,12 @@ describe("Angular service", () => {
return () => new OktaAuthService(config);
};

it("starts tokenService during construction", () => {
const tokenManagerStart = jest.spyOn(OktaAuth.TokenManager.prototype, 'start');
createInstance(VALID_CONFIG)();
expect(tokenManagerStart).toBeCalled();
});

describe("configuration", () => {
it("should throw if no issuer is provided", () => {
expect(createInstance()).toThrow();
Expand Down