1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 13:19:43 +02:00

Allow admins to set subdomain for their instance

Fixes #209

Admins can see and set subdomain for their instance.

Self-host customers only!
This commit is contained in:
Harvey Kandola 2019-02-27 13:49:59 +00:00
parent af9bc25660
commit f828583b49
6 changed files with 25 additions and 3 deletions

View file

@ -15,10 +15,10 @@ import (
"bytes" "bytes"
"database/sql" "database/sql"
"encoding/json" "encoding/json"
"github.com/documize/community/model/audit"
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"strings"
"github.com/documize/community/core/env" "github.com/documize/community/core/env"
"github.com/documize/community/core/request" "github.com/documize/community/core/request"
@ -26,6 +26,7 @@ import (
"github.com/documize/community/core/streamutil" "github.com/documize/community/core/streamutil"
"github.com/documize/community/domain" "github.com/documize/community/domain"
"github.com/documize/community/domain/store" "github.com/documize/community/domain/store"
"github.com/documize/community/model/audit"
"github.com/documize/community/model/org" "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) err = json.Unmarshal(body, &org)
org.RefID = ctx.OrgID org.RefID = ctx.OrgID
org.Domain = strings.ToLower(org.Domain)
ctx.Transaction, err = h.Runtime.Db.Beginx() ctx.Transaction, err = h.Runtime.Db.Beginx()
if err != nil { if err != nil {

View file

@ -115,7 +115,7 @@ func (s Store) UpdateOrganization(ctx domain.RequestContext, org org.Organizatio
org.Revised = time.Now().UTC() org.Revised = time.Now().UTC()
_, err = ctx.Transaction.NamedExec(`UPDATE dmz_org SET _, 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 c_anonaccess=:allowanonymousaccess, c_maxtags=:maxtags, c_theme=:theme, c_revised=:revised
WHERE c_refid=:refid`, WHERE c_refid=:refid`,
&org) &org)

View file

@ -19,7 +19,9 @@ import Component from '@ember/component';
export default Component.extend(Notifier, { export default Component.extend(Notifier, {
appMeta: service(), appMeta: service(),
router: service(),
maxTags: 3, maxTags: 3,
domain: '',
titleEmpty: empty('model.general.title'), titleEmpty: empty('model.general.title'),
messageEmpty: empty('model.general.message'), messageEmpty: empty('model.general.message'),
conversionEndpointEmpty: empty('model.general.conversionEndpoint'), conversionEndpointEmpty: empty('model.general.conversionEndpoint'),
@ -30,6 +32,7 @@ export default Component.extend(Notifier, {
didReceiveAttrs() { didReceiveAttrs() {
this._super(...arguments); this._super(...arguments);
this.set('maxTags', this.get('model.general.maxTags')); this.set('maxTags', this.get('model.general.maxTags'));
this.set('domain', this.get('model.general.domain'));
}, },
didInsertElement() { didInsertElement() {
@ -110,11 +113,20 @@ export default Component.extend(Notifier, {
this.set('model.general.maxTags', this.get('maxTags')); 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.get('onUpdate')().then(() => {
this.notifySuccess('Saved'); this.notifySuccess('Saved');
set(this, 'titleError', false); set(this, 'titleError', false);
set(this, 'messageError', false); set(this, 'messageError', false);
set(this, 'conversionEndpointError', false); set(this, 'conversionEndpointError', false);
if (domainChanged) {
let router = this.get('router');
router.transitionTo('auth.login');
}
}); });
}, },

View file

@ -16,6 +16,7 @@ export default Model.extend({
title: attr('string'), title: attr('string'),
message: attr('string'), message: attr('string'),
email: attr('string'), email: attr('string'),
domain: attr('string'),
conversionEndpoint: attr('string'), conversionEndpoint: attr('string'),
allowAnonymousAccess: attr('boolean', { defaultValue: false }), allowAnonymousAccess: attr('boolean', { defaultValue: false }),
maxTags: attr('number', {defaultValue: 3}), maxTags: attr('number', {defaultValue: 3}),

View file

@ -10,9 +10,9 @@
// https://documize.com // https://documize.com
import { inject as service } from '@ember/service'; import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
import RSVP from 'rsvp'; import RSVP from 'rsvp';
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
import Route from '@ember/routing/route';
export default Route.extend(AuthenticatedRouteMixin, { export default Route.extend(AuthenticatedRouteMixin, {
orgService: service('organization'), orgService: service('organization'),

View file

@ -22,6 +22,13 @@
</div> </div>
<small class="form-text text-muted">You can choose to upload a small logo (e.g. 64px x 64px)</small> <small class="form-text text-muted">You can choose to upload a small logo (e.g. 64px x 64px)</small>
</div> </div>
{{#if (eq appMeta.location "selfhost")}}
<div class="form-group">
<label for="orgDomain">Site URL Subdomain</label>
{{input id="orgDomain" type="text" value=domain class="form-control" placeholder="e.g. docs"}}
<small class="form-text text-muted">If you are hosting on "docs.example.org" then the subdomain value should be set to "doc"</small>
</div>
{{/if}}
<div class="form-group"> <div class="form-group">
<label>Public Spaces Viewable By Anonymous Users</label> <label>Public Spaces Viewable By Anonymous Users</label>