Skip to content

Commit

Permalink
Replaced document by this.document #773
Browse files Browse the repository at this point in the history
Replaced document by this.document this uses the injected service instead of the native object.
  • Loading branch information
kristofdegrave authored Apr 6, 2020
1 parent ff82dd9 commit 678ff95
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions projects/lib/src/oauth-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -979,21 +979,21 @@ export class OAuthService extends AuthConfig implements OnDestroy {
);
}

if (typeof document === 'undefined') {
if (typeof this.document === 'undefined') {
throw new Error('silent refresh is not supported on this platform');
}

const existingIframe = document.getElementById(
const existingIframe = this.document.getElementById(
this.silentRefreshIFrameName
);

if (existingIframe) {
document.body.removeChild(existingIframe);
this.document.body.removeChild(existingIframe);
}

this.silentRefreshSubject = claims['sub'];

const iframe = document.createElement('iframe');
const iframe = this.document.createElement('iframe');
iframe.id = this.silentRefreshIFrameName;

this.setupSilentRefreshEventListener();
Expand All @@ -1005,7 +1005,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
if (!this.silentRefreshShowIFrame) {
iframe.style['display'] = 'none';
}
document.body.appendChild(iframe);
this.document.body.appendChild(iframe);
});

const errors = this.events.pipe(
Expand Down Expand Up @@ -1177,7 +1177,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
);
return false;
}
if (typeof document === 'undefined') {
if (typeof this.document === 'undefined') {
return false;
}

Expand Down Expand Up @@ -1299,20 +1299,20 @@ export class OAuthService extends AuthConfig implements OnDestroy {
return;
}

const existingIframe = document.getElementById(this.sessionCheckIFrameName);
const existingIframe = this.document.getElementById(this.sessionCheckIFrameName);
if (existingIframe) {
document.body.removeChild(existingIframe);
this.document.body.removeChild(existingIframe);
}

const iframe = document.createElement('iframe');
const iframe = this.document.createElement('iframe');
iframe.id = this.sessionCheckIFrameName;

this.setupSessionCheckEventListener();

const url = this.sessionCheckIFrameUrl;
iframe.setAttribute('src', url);
iframe.style.display = 'none';
document.body.appendChild(iframe);
this.document.body.appendChild(iframe);

this.startSessionCheckTimer();
}
Expand All @@ -1335,7 +1335,7 @@ export class OAuthService extends AuthConfig implements OnDestroy {
}

public checkSession(): void {
const iframe: any = document.getElementById(this.sessionCheckIFrameName);
const iframe: any = this.document.getElementById(this.sessionCheckIFrameName);

if (!iframe) {
this.logger.warn(
Expand Down

0 comments on commit 678ff95

Please sign in to comment.