From 420e778eb627ebc817a5295db2547ae8c322d10b Mon Sep 17 00:00:00 2001 From: Eliot Berriot <contact@eliotberriot.com> Date: Sat, 11 Aug 2018 14:20:08 +0200 Subject: [PATCH] Fixed #476: invitation code not prefilled in form when accessing invitation link --- changes/changelog.d/476.bugfix | 1 + front/src/App.vue | 6 +----- front/src/router/index.js | 2 +- front/src/store/instance.js | 14 +++++++++++++- front/yarn.lock | 6 +++--- 5 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 changes/changelog.d/476.bugfix diff --git a/changes/changelog.d/476.bugfix b/changes/changelog.d/476.bugfix new file mode 100644 index 0000000000..e2efbc0a3a --- /dev/null +++ b/changes/changelog.d/476.bugfix @@ -0,0 +1 @@ +Fixed invitation code not prefilled in form when accessing invitation link (#476) diff --git a/front/src/App.vue b/front/src/App.vue index e0c4070a87..f80020e939 100644 --- a/front/src/App.vue +++ b/front/src/App.vue @@ -165,11 +165,7 @@ export default { messages: state => state.ui.messages }), suggestedInstances () { - let rootUrl = ( - window.location.protocol + '//' + window.location.hostname + - (window.location.port ? ':' + window.location.port : '') - ) - let instances = [rootUrl, 'https://demo.funkwhale.audio'] + let instances = [this.$store.getters['instance/defaultUrl'](), 'https://demo.funkwhale.audio'] return instances }, version () { diff --git a/front/src/router/index.js b/front/src/router/index.js index 1747c88581..0d8a0b9367 100644 --- a/front/src/router/index.js +++ b/front/src/router/index.js @@ -100,7 +100,7 @@ export default new Router({ name: 'signup', component: Signup, props: (route) => ({ - invitation: route.query.invitation + defaultInvitation: route.query.invitation }) }, { diff --git a/front/src/store/instance.js b/front/src/store/instance.js index 64e48f7b4b..5610b0ec7f 100644 --- a/front/src/store/instance.js +++ b/front/src/store/instance.js @@ -2,6 +2,13 @@ import axios from 'axios' import logger from '@/logging' import _ from 'lodash' +function getDefaultUrl () { + return ( + window.location.protocol + '//' + window.location.hostname + + (window.location.port ? ':' + window.location.port : '') + ) +} + export default { namespaced: true, state: { @@ -71,6 +78,9 @@ export default { } }, getters: { + defaultUrl: (state) => () => { + return getDefaultUrl() + }, absoluteUrl: (state) => (relativeUrl) => { if (relativeUrl.startsWith('http')) { return relativeUrl @@ -78,7 +88,9 @@ export default { if (state.instanceUrl.endsWith('/') && relativeUrl.startsWith('/')) { relativeUrl = relativeUrl.slice(1) } - return state.instanceUrl + relativeUrl + + let instanceUrl = state.instanceUrl || getDefaultUrl() + return instanceUrl + relativeUrl } }, actions: { diff --git a/front/yarn.lock b/front/yarn.lock index 6bc14175f6..764052bbfe 100644 --- a/front/yarn.lock +++ b/front/yarn.lock @@ -7522,9 +7522,9 @@ void-elements@^2.0.0, void-elements@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" -vue-gettext@^2.0.31: - version "2.0.31" - resolved "https://registry.yarnpkg.com/vue-gettext/-/vue-gettext-2.0.31.tgz#0f113bea6aed747e2a809ae4a0db83eaac0b07fc" +vue-gettext@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/vue-gettext/-/vue-gettext-2.1.0.tgz#e4932037a8601412dd9f7d7d7a5d60c4bdb341d1" vue-hot-reload-api@^2.1.0: version "2.3.0" -- GitLab