Skip to content

Commit 68124c5

Browse files
committed
Fix issues with OIDC and Vue Router
1 parent f097f3f commit 68124c5

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

src/StacBrowser.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ for(let key in CONFIG) {
113113
default: ['object', 'function'].includes(typeof CONFIG[key]) ? () => CONFIG[key] : CONFIG[key]
114114
};
115115
Watchers[key] = {
116-
immediate: false, // Changed from true to avoid accessing store before it's ready
117-
deep: ['object', 'array'].includes(typeof CONFIG[key]), // Deep watch for objects and arrays
116+
immediate: true,
117+
deep: ['object', 'array'].includes(typeof CONFIG[key]),
118118
handler: async function(newValue) {
119119
await this.$store.dispatch('config', {
120120
[key]: newValue

src/auth/apiKey.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import i18n from '../i18n';
33

44
export default class ApiKey extends Auth {
55

6-
constructor(options, changeListener, router) {
7-
super(options, changeListener, router);
6+
constructor(router, options, changeListener) {
7+
super(router, options, changeListener);
88
}
99

1010
getButtonTitle() {
@@ -22,7 +22,7 @@ export default class ApiKey extends Auth {
2222
}
2323

2424
async logout(/*credentials*/) {
25-
if (this.router.currentRoute.name !== 'logout') {
25+
if (this.router.currentRoute.value.name !== 'logout') {
2626
this.router.push('/auth/logout');
2727
}
2828
return true;

src/auth/basic.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import Utils from "../utils";
44

55
export default class BasicAuth extends Auth {
66

7-
constructor(options, changeListener, router) {
8-
super(options, changeListener, router);
7+
constructor(router, options, changeListener) {
8+
super(router, options, changeListener);
99
}
1010

1111
getComponent() {
@@ -23,7 +23,7 @@ export default class BasicAuth extends Auth {
2323
}
2424

2525
async logout(/*credentials*/) {
26-
if (this.router.currentRoute.name !== 'logout') {
26+
if (this.router.currentRoute.value.name !== 'logout') {
2727
this.router.push('/auth/logout');
2828
}
2929
return true;

src/auth/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ export default class Auth {
66
/**
77
* Constructs the authentication method.
88
*
9+
* @param {Router} router The Vue router instance
910
* @param {Object.<string, *>} options Any potential options the authentication method needs
1011
* @param {Function} changeListener A change listener with two parameters: loggedIn (boolean) and credentials (string|null)
11-
* @param {Router} router The Vue router instance
1212
*/
13-
constructor(options = {}, changeListener = null, router = null) {
13+
constructor(router, options = {}, changeListener = null) {
1414
this.options = options;
1515
this.changeListener = changeListener;
1616
this.router = router;
@@ -114,20 +114,20 @@ export default class Auth {
114114
}
115115
}
116116

117-
static async create(config, changeListener, router) {
118-
let method = new Auth();
117+
static async create(router, config, changeListener) {
118+
let method = new Auth(router, config, changeListener);
119119
if (Utils.isObject(config)) {
120120
if (config.type === 'http' && config.scheme === 'basic') {
121121
const BasicAuth = (await import('./basic')).default;
122-
method = new BasicAuth(config, changeListener, router);
122+
method = new BasicAuth(router, config, changeListener);
123123
}
124124
else if (config.type === 'apiKey') {
125125
const ApIKey = (await import('./apiKey')).default;
126-
method = new ApIKey(config, changeListener, router);
126+
method = new ApIKey(router, config, changeListener);
127127
}
128128
else if (config.type === 'openIdConnect') {
129129
const OIDC = (await import('./oidc')).default;
130-
method = new OIDC(config, changeListener, router);
130+
method = new OIDC(router, config, changeListener);
131131
}
132132
}
133133
await method.init();

src/auth/oidc.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { UserManager } from 'oidc-client-ts';
66

77
export default class OIDC extends Auth {
88

9-
constructor(options, changeListener, router) {
10-
super(options, changeListener, router);
9+
constructor(router, options, changeListener) {
10+
super(router, options, changeListener);
1111

1212
const oidcConfig = {
1313
authority: options.openIdConnectUrl.replace('/.well-known/openid-configuration', ''),
@@ -26,7 +26,7 @@ export default class OIDC extends Auth {
2626
}
2727

2828
setOriginalUri() {
29-
this.browserStorage.set('oidc-original-uri', this.router?.currentRoute?.fullPath || window.location.href);
29+
this.browserStorage.set('oidc-original-uri', this.router.currentRoute.value.fullPath);
3030
}
3131

3232
restoreOriginalUri() {

src/store/auth.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function getStore(router) {
1818
// Wrap in a function and use the getter instead of the state
1919
// Unfortunately, some auth libraries have internal state, which vuex doesn't like
2020
// and thus reports: "do not mutate vuex store state outside mutation handlers."
21-
method: () => new Auth(),
21+
method: () => new Auth(router),
2222
actions: [],
2323
credentials: null,
2424
inProgress: false
@@ -82,7 +82,7 @@ export default function getStore(router) {
8282
const storage = new BrowserStorage(true);
8383
storage.set('authConfig', config);
8484

85-
const newAuth = await Auth.create(config, changeListener, router);
85+
const newAuth = await Auth.create(router, config, changeListener);
8686
cx.commit('setMethod', newAuth);
8787
},
8888
async requestLogin(cx) {

0 commit comments

Comments
 (0)