diff --git a/domain/organization/endpoint.go b/domain/organization/endpoint.go index b96ba761..7b82ce35 100644 --- a/domain/organization/endpoint.go +++ b/domain/organization/endpoint.go @@ -15,10 +15,10 @@ import ( "bytes" "database/sql" "encoding/json" - "github.com/documize/community/model/audit" "io" "io/ioutil" "net/http" + "strings" "github.com/documize/community/core/env" "github.com/documize/community/core/request" @@ -26,6 +26,7 @@ import ( "github.com/documize/community/core/streamutil" "github.com/documize/community/domain" "github.com/documize/community/domain/store" + "github.com/documize/community/model/audit" "github.com/documize/community/model/org" ) @@ -82,6 +83,7 @@ func (h *Handler) Update(w http.ResponseWriter, r *http.Request) { err = json.Unmarshal(body, &org) org.RefID = ctx.OrgID + org.Domain = strings.ToLower(org.Domain) ctx.Transaction, err = h.Runtime.Db.Beginx() if err != nil { diff --git a/domain/organization/store.go b/domain/organization/store.go index 0c7ad275..86199f30 100644 --- a/domain/organization/store.go +++ b/domain/organization/store.go @@ -115,7 +115,7 @@ func (s Store) UpdateOrganization(ctx domain.RequestContext, org org.Organizatio org.Revised = time.Now().UTC() _, err = ctx.Transaction.NamedExec(`UPDATE dmz_org SET - c_title=:title, c_message=:message, c_service=:conversionendpoint, c_email=:email, + c_title=:title, c_message=:message, c_service=:conversionendpoint, c_email=:email, c_domain=:domain, c_anonaccess=:allowanonymousaccess, c_maxtags=:maxtags, c_theme=:theme, c_revised=:revised WHERE c_refid=:refid`, &org) diff --git a/gui/app/components/customize/general-settings.js b/gui/app/components/customize/general-settings.js index 461c727a..1dd0af49 100644 --- a/gui/app/components/customize/general-settings.js +++ b/gui/app/components/customize/general-settings.js @@ -19,7 +19,9 @@ import Component from '@ember/component'; export default Component.extend(Notifier, { appMeta: service(), + router: service(), maxTags: 3, + domain: '', titleEmpty: empty('model.general.title'), messageEmpty: empty('model.general.message'), conversionEndpointEmpty: empty('model.general.conversionEndpoint'), @@ -30,6 +32,7 @@ export default Component.extend(Notifier, { didReceiveAttrs() { this._super(...arguments); this.set('maxTags', this.get('model.general.maxTags')); + this.set('domain', this.get('model.general.domain')); }, didInsertElement() { @@ -110,11 +113,20 @@ export default Component.extend(Notifier, { this.set('model.general.maxTags', this.get('maxTags')); + let domainChanged = this.get('model.general.domain') !== this.get('domain').toLowerCase(); + this.set('model.general.domain', this.get('domain').toLowerCase()); + this.get('onUpdate')().then(() => { this.notifySuccess('Saved'); set(this, 'titleError', false); set(this, 'messageError', false); set(this, 'conversionEndpointError', false); + + + if (domainChanged) { + let router = this.get('router'); + router.transitionTo('auth.login'); + } }); }, diff --git a/gui/app/models/organization.js b/gui/app/models/organization.js index 289ee030..77888908 100644 --- a/gui/app/models/organization.js +++ b/gui/app/models/organization.js @@ -16,6 +16,7 @@ export default Model.extend({ title: attr('string'), message: attr('string'), email: attr('string'), + domain: attr('string'), conversionEndpoint: attr('string'), allowAnonymousAccess: attr('boolean', { defaultValue: false }), maxTags: attr('number', {defaultValue: 3}), diff --git a/gui/app/pods/customize/general/route.js b/gui/app/pods/customize/general/route.js index dd71d0b0..e3915d0b 100644 --- a/gui/app/pods/customize/general/route.js +++ b/gui/app/pods/customize/general/route.js @@ -10,9 +10,9 @@ // https://documize.com import { inject as service } from '@ember/service'; -import Route from '@ember/routing/route'; import RSVP from 'rsvp'; import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; +import Route from '@ember/routing/route'; export default Route.extend(AuthenticatedRouteMixin, { orgService: service('organization'), diff --git a/gui/app/templates/components/customize/general-settings.hbs b/gui/app/templates/components/customize/general-settings.hbs index 4e0cf850..42a0852f 100644 --- a/gui/app/templates/components/customize/general-settings.hbs +++ b/gui/app/templates/components/customize/general-settings.hbs @@ -22,6 +22,13 @@ You can choose to upload a small logo (e.g. 64px x 64px) + {{#if (eq appMeta.location "selfhost")}} +
+ + {{input id="orgDomain" type="text" value=domain class="form-control" placeholder="e.g. docs"}} + If you are hosting on "docs.example.org" then the subdomain value should be set to "doc" +
+{{/if}}