From e5476f884b091efa9d9b198ac4e9a4c36b60de57 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Mon, 20 Jul 2020 19:44:39 +0200 Subject: [PATCH] Fix edition of source with redirections outside happyDNS --- api/source_settings.go | 2 ++ htdocs/src/components/hSourceState.vue | 2 +- htdocs/src/mixins/sourceState.js | 10 ++++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/api/source_settings.go b/api/source_settings.go index 89b6071..9b8f16e 100644 --- a/api/source_settings.go +++ b/api/source_settings.go @@ -87,6 +87,7 @@ func getSourceSettingsState(cfg *config.Options, req *RequestResources, body io. if uss.Recall != nil { req.Session.GetValue(fmt.Sprintf("source-creation-%d", *uss.Recall), src) req.Session.GetValue(fmt.Sprintf("source-creation-%d-name", *uss.Recall), &uss.Name) + req.Session.GetValue(fmt.Sprintf("source-creation-%d-id", *uss.Recall), &uss.Id) req.Session.GetValue(fmt.Sprintf("source-creation-%d-next", *uss.Recall), &uss.Redirect) } @@ -104,6 +105,7 @@ func getSourceSettingsState(cfg *config.Options, req *RequestResources, body io. key, recallid := req.Session.FindNewKey("source-creation-") req.Session.SetValue(key, src) req.Session.SetValue(key+"-name", uss.Name) + req.Session.SetValue(key+"-id", uss.Id) if uss.Redirect != nil { req.Session.SetValue(key+"-next", *uss.Redirect) } diff --git a/htdocs/src/components/hSourceState.vue b/htdocs/src/components/hSourceState.vue index b3000ae..f2d2711 100644 --- a/htdocs/src/components/hSourceState.vue +++ b/htdocs/src/components/hSourceState.vue @@ -87,7 +87,7 @@ export default { }, state: { type: Number, - default: 1 + default: 0 }, value: { type: Object, diff --git a/htdocs/src/mixins/sourceState.js b/htdocs/src/mixins/sourceState.js index 4ef5cd7..503b289 100644 --- a/htdocs/src/mixins/sourceState.js +++ b/htdocs/src/mixins/sourceState.js @@ -58,10 +58,11 @@ export default { response => { if (response.data.form) { this.form = response.data.form - if (cbSuccess) { + this.state = toState + if (response.data.redirect && window.location.pathname !== response.data.redirect) { + this.$router.push(response.data.redirect) + } else if (cbSuccess) { cbSuccess(toState) - } else { - this.state = toState } } else if (response.data.Source) { this.$root.$bvToast.toast( @@ -72,12 +73,13 @@ export default { toaster: 'b-toaster-content-right' } ) + this.state = toState if (response.data.redirect && window.location.pathname !== response.data.redirect) { this.$router.push(response.data.redirect) } else if (cbSuccess) { cbSuccess(toState, response.data.Source) } else { - this.state = toState + this.$router.push('/sources/' + encodeURIComponent(response.data.Source._id) + '/domains') } } },