Skip to content

Commit 707cb6d

Browse files
committed
add popupWindowFeatures to allow customization of popup window
1 parent c391207 commit 707cb6d

File tree

6 files changed

+25
-8
lines changed

6 files changed

+25
-8
lines changed

dist/oidc-client.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/PopupNavigator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import PopupWindow from './PopupWindow';
66

77
export default class PopupNavigator {
88

9-
prepare() {
10-
let popup = new PopupWindow();
9+
prepare(params) {
10+
let popup = new PopupWindow(params);
1111
return Promise.resolve(popup);
1212
}
1313

src/PopupWindow.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
import Log from './Log';
55

66
const CheckForPopupClosedInterval = 500;
7+
const DefaultPopupFeatures = 'location=no,toolbar=no,width=500,height=500,left=100,top=100';
78

89
export default class PopupWindow {
910

10-
constructor() {
11+
constructor(params) {
1112
Log.info("PopupWindow.ctor");
1213

1314
this._promise = new Promise((resolve, reject) => {
@@ -17,8 +18,10 @@ export default class PopupWindow {
1718

1819
this._boundMessageEvent = this._message.bind(this);
1920
window.addEventListener("message", this._boundMessageEvent, false);
21+
22+
let features = params.popupWindowFeatures || DefaultPopupFeatures;
2023

21-
this._popup = window.open('', '_blank', 'location=no,toolbar=no,width=500,height=500');
24+
this._popup = window.open('', '_blank', features);
2225
if (this._popup) {
2326
Log.info("popup successfully created");
2427
this._checkForPopupClosedTimer = window.setInterval(this._checkForPopupClosed.bind(this), CheckForPopupClosedInterval);

src/UserManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export default class UserManager extends OidcClient {
150150
_signinStart(args, navigator, navigatorParams = {}) {
151151
Log.info("_signinStart");
152152

153-
return navigator.prepare().then(handle => {
153+
return navigator.prepare(navigatorParams).then(handle => {
154154
Log.info("got navigator window handle");
155155

156156
return this.createSigninRequest(args).then(signinRequest => {
@@ -182,7 +182,7 @@ export default class UserManager extends OidcClient {
182182
_signoutStart(args = {}, navigator, navigatorParams = {}) {
183183
Log.info("_signoutStart");
184184

185-
return navigator.prepare().then(handle => {
185+
return navigator.prepare(navigatorParams).then(handle => {
186186
Log.info("got navigator window handle");
187187

188188
return this.getUser().then(user => {

src/UserManagerSettings.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ const DefaultAccessTokenExpiringNotificationTime = 60;
99
export default class UserManagerSettings extends OidcClientSettings {
1010
constructor({
1111
popup_redirect_uri,
12+
popupWindowFeatures,
1213
silent_redirect_uri,
1314
automaticSilentRenew = false,
1415
accessTokenExpiringNotificationTime = DefaultAccessTokenExpiringNotificationTime
1516
} = {}) {
1617
super(arguments[0]);
1718

1819
this._popup_redirect_uri = popup_redirect_uri;
20+
this._popupWindowFeatures = popupWindowFeatures;
1921
this._silent_redirect_uri = silent_redirect_uri;
2022
this._automaticSilentRenew = !!automaticSilentRenew;
2123
this._accessTokenExpiringNotificationTime = accessTokenExpiringNotificationTime;
@@ -24,6 +26,9 @@ export default class UserManagerSettings extends OidcClientSettings {
2426
get popup_redirect_uri(){
2527
return this._popup_redirect_uri;
2628
}
29+
get popupWindowFeatures(){
30+
return this._popupWindowFeatures;
31+
}
2732

2833
get silent_redirect_uri() {
2934
return this._silent_redirect_uri;

test/unit/UserManagerSettings.spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ describe("UserManagerSettings", function () {
3636
});
3737

3838
});
39+
40+
describe("popupWindowFeatures", function () {
41+
42+
it("should return value from initial settings", function () {
43+
let subject = new UserManagerSettings({ popupWindowFeatures: 'foo' });
44+
subject.popupWindowFeatures.should.equal('foo');
45+
});
46+
47+
});
3948

4049
describe("silent_redirect_uri", function () {
4150

0 commit comments

Comments
 (0)