diff options
author | Bastien Wirtz <bastien.wirtz@gmail.com> | 2020-07-13 09:16:47 -0700 |
---|---|---|
committer | Bastien Wirtz <bastien.wirtz@gmail.com> | 2020-07-13 09:16:47 -0700 |
commit | 0ae40f78f837e95ba2ccb04025c6bebcc09d7ab4 (patch) | |
tree | 702ffa5dde050034772b3955bffb3eca4d190610 | |
parent | 6de53c49b357df0bb77f1ea5edef20dec6cf3133 (diff) | |
download | homer-0ae40f78f837e95ba2ccb04025c6bebcc09d7ab4.tar.gz homer-0ae40f78f837e95ba2ccb04025c6bebcc09d7ab4.tar.zst homer-0ae40f78f837e95ba2ccb04025c6bebcc09d7ab4.zip |
Auth redirection support
-rw-r--r-- | src/App.vue | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/App.vue b/src/App.vue index b13b98f..d7054a7 100644 --- a/src/App.vue +++ b/src/App.vue | |||
@@ -150,7 +150,13 @@ export default { | |||
150 | }, | 150 | }, |
151 | created: async function () { | 151 | created: async function () { |
152 | const defaults = jsyaml.load(defaultConfig); | 152 | const defaults = jsyaml.load(defaultConfig); |
153 | let config = await this.getConfig(); | 153 | let config; |
154 | try { | ||
155 | config = await this.getConfig(); | ||
156 | } catch (error) { | ||
157 | console.log(error); | ||
158 | config = this.handleErrors("⚠️ Error loading configuration", error); | ||
159 | } | ||
154 | this.config = merge(defaults, config); | 160 | this.config = merge(defaults, config); |
155 | this.services = this.config.services; | 161 | this.services = this.config.services; |
156 | document.title = `${this.config.title} | ${this.config.subtitle}`; | 162 | document.title = `${this.config.title} | ${this.config.subtitle}`; |
@@ -158,8 +164,13 @@ export default { | |||
158 | methods: { | 164 | methods: { |
159 | getConfig: function (path = "assets/config.yml") { | 165 | getConfig: function (path = "assets/config.yml") { |
160 | return fetch(path).then((response) => { | 166 | return fetch(path).then((response) => { |
167 | if (response.redirected) { | ||
168 | // This allows to work with authentication proxies. | ||
169 | window.location.href = response.url; | ||
170 | return; | ||
171 | } | ||
161 | if (!response.ok) { | 172 | if (!response.ok) { |
162 | throw Error(response.statusText); | 173 | throw Error(`${response.statusText}: ${response.body}`); |
163 | } | 174 | } |
164 | 175 | ||
165 | const that = this; | 176 | const that = this; |
@@ -173,9 +184,6 @@ export default { | |||
173 | return that.getConfig(config.externalConfig); | 184 | return that.getConfig(config.externalConfig); |
174 | } | 185 | } |
175 | return config; | 186 | return config; |
176 | }) | ||
177 | .catch((error) => { | ||
178 | return this.handleErrors("⚠️ Error loading configuration", error); | ||
179 | }); | 187 | }); |
180 | }); | 188 | }); |
181 | }, | 189 | }, |