mirror of
https://github.com/documize/community.git
synced 2025-07-19 13:19:43 +02:00
parent
4445f41801
commit
4e082b4159
26 changed files with 937 additions and 611 deletions
|
@ -18,24 +18,24 @@ const {
|
||||||
} = Ember;
|
} = Ember;
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
titleEmpty: computed.empty('model.title'),
|
titleEmpty: computed.empty('model.general.title'),
|
||||||
messageEmpty: computed.empty('model.message'),
|
messageEmpty: computed.empty('model.general.message'),
|
||||||
hasTitleInputError: computed.and('titleEmpty', 'titleError'),
|
hasTitleInputError: computed.and('titleEmpty', 'titleError'),
|
||||||
hasMessageInputError: computed.and('messageEmpty', 'messageError'),
|
hasMessageInputError: computed.and('messageEmpty', 'messageError'),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
save() {
|
save() {
|
||||||
if (isEmpty(this.get('model.title'))) {
|
if (isEmpty(this.get('model.general.title'))) {
|
||||||
set(this, 'titleError', true);
|
set(this, 'titleError', true);
|
||||||
return $("#siteTitle").focus();
|
return $("#siteTitle").focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEmpty(this.get('model.message'))) {
|
if (isEmpty(this.get('model.general.message'))) {
|
||||||
set(this, 'messageError', true);
|
set(this, 'messageError', true);
|
||||||
return $("#siteMessage").focus();
|
return $("#siteMessage").focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.model.set('allowAnonymousAccess', Ember.$("#allowAnonymousAccess").prop('checked'));
|
this.model.general.set('allowAnonymousAccess', Ember.$("#allowAnonymousAccess").prop('checked'));
|
||||||
this.get('save')().then(() => {
|
this.get('save')().then(() => {
|
||||||
set(this, 'titleError', false);
|
set(this, 'titleError', false);
|
||||||
set(this, 'messageError', false);
|
set(this, 'messageError', false);
|
||||||
|
|
52
app/app/components/global-settings.js
Normal file
52
app/app/components/global-settings.js
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
|
//
|
||||||
|
// This software (Documize Community Edition) is licensed under
|
||||||
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
|
//
|
||||||
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
|
// by contacting <sales@documize.com>.
|
||||||
|
//
|
||||||
|
// https://documize.com
|
||||||
|
|
||||||
|
import Ember from 'ember';
|
||||||
|
|
||||||
|
const {
|
||||||
|
computed
|
||||||
|
} = Ember;
|
||||||
|
|
||||||
|
export default Ember.Component.extend({
|
||||||
|
SMTPHostEmptyError: computed.empty('model.global.host'),
|
||||||
|
SMTPPortEmptyError: computed.empty('model.global.port'),
|
||||||
|
SMTPSenderEmptyError: computed.empty('model.global.sender'),
|
||||||
|
SMTPUserIdEmptyError: computed.empty('model.global.userid'),
|
||||||
|
SMTPPasswordEmptyError: computed.empty('model.global.password'),
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
save() {
|
||||||
|
if (this.get('SMTPHostEmptyError')) {
|
||||||
|
$("#smtp-host").focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.get('SMTPPortEmptyError')) {
|
||||||
|
$("#smtp-port").focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.get('SMTPSenderEmptyError')) {
|
||||||
|
$("#smtp-sender").focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.get('SMTPUserIdEmptyError')) {
|
||||||
|
$("#smtp-userid").focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.get('SMTPPasswordEmptyError')) {
|
||||||
|
$("#smtp-password").focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.get('save')().then(() => {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
|
@ -22,6 +22,7 @@ export default Model.extend({
|
||||||
active: attr('boolean', { defaultValue: false }),
|
active: attr('boolean', { defaultValue: false }),
|
||||||
editor: attr('boolean', { defaultValue: false }),
|
editor: attr('boolean', { defaultValue: false }),
|
||||||
admin: attr('boolean', { defaultValue: false }),
|
admin: attr('boolean', { defaultValue: false }),
|
||||||
|
global: attr('boolean', { defaultValue: false }),
|
||||||
accounts: attr(),
|
accounts: attr(),
|
||||||
created: attr(),
|
created: attr(),
|
||||||
revised: attr(),
|
revised: attr(),
|
||||||
|
|
|
@ -17,7 +17,7 @@ export default Ember.Controller.extend(NotifierMixin, {
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
save() {
|
save() {
|
||||||
return this.get('orgService').save(this.model).then(() => {
|
return this.get('orgService').save(this.model.general).then(() => {
|
||||||
this.showNotification('Saved');
|
this.showNotification('Saved');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
|
import RSVP from 'rsvp';
|
||||||
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
|
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
|
||||||
|
|
||||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||||
|
@ -25,10 +26,13 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||||
|
|
||||||
model() {
|
model() {
|
||||||
let orgId = this.get("appMeta.orgId");
|
let orgId = this.get("appMeta.orgId");
|
||||||
return this.get('orgService').getOrg(orgId);
|
|
||||||
|
return RSVP.hash({
|
||||||
|
general: this.get('orgService').getOrg(orgId)
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
activate() {
|
activate() {
|
||||||
document.title = "Settings | Documize";
|
document.title = "Settings | Documize";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
<div class="input-form form-borderless">
|
<div class="input-form form-borderless">
|
||||||
{{general-settings model=model save=(action 'save')}}
|
{{general-settings model=model save=(action 'save')}}
|
||||||
</div>
|
</div>
|
||||||
|
|
27
app/app/pods/customize/global/controller.js
Normal file
27
app/app/pods/customize/global/controller.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
|
//
|
||||||
|
// This software (Documize Community Edition) is licensed under
|
||||||
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
|
//
|
||||||
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
|
// by contacting <sales@documize.com>.
|
||||||
|
//
|
||||||
|
// https://documize.com
|
||||||
|
|
||||||
|
import Ember from 'ember';
|
||||||
|
import NotifierMixin from "../../../mixins/notifier";
|
||||||
|
|
||||||
|
export default Ember.Controller.extend(NotifierMixin, {
|
||||||
|
global: Ember.inject.service(),
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
save() {
|
||||||
|
if(this.get('session.isGlobalAdmin')) {
|
||||||
|
return this.get('global').saveConfig(this.model.global).then(() => {
|
||||||
|
this.showNotification('Saved');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
36
app/app/pods/customize/global/route.js
Normal file
36
app/app/pods/customize/global/route.js
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
|
//
|
||||||
|
// This software (Documize Community Edition) is licensed under
|
||||||
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
|
//
|
||||||
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
|
// by contacting <sales@documize.com>.
|
||||||
|
//
|
||||||
|
// https://documize.com
|
||||||
|
|
||||||
|
import Ember from 'ember';
|
||||||
|
import RSVP from 'rsvp';
|
||||||
|
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
|
||||||
|
|
||||||
|
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||||
|
appMeta: Ember.inject.service(),
|
||||||
|
session: Ember.inject.service(),
|
||||||
|
global: Ember.inject.service(),
|
||||||
|
|
||||||
|
beforeModel() {
|
||||||
|
if (!this.get("session.isGlobalAdmin")) {
|
||||||
|
this.transitionTo('auth.login');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
model() {
|
||||||
|
return RSVP.hash({
|
||||||
|
global: this.get('global').getConfig()
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
activate() {
|
||||||
|
document.title = "Settings | Documize";
|
||||||
|
}
|
||||||
|
});
|
3
app/app/pods/customize/global/template.hbs
Normal file
3
app/app/pods/customize/global/template.hbs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<div class="input-form form-borderless">
|
||||||
|
{{global-settings model=model save=(action 'save')}}
|
||||||
|
</div>
|
|
@ -8,6 +8,9 @@
|
||||||
{{#link-to 'customize.general' activeClass='selected' class="option" tagName="li"}}General{{/link-to}}
|
{{#link-to 'customize.general' activeClass='selected' class="option" tagName="li"}}General{{/link-to}}
|
||||||
{{#link-to 'customize.folders' activeClass='selected' class="option" tagName="li"}}Spaces{{/link-to}}
|
{{#link-to 'customize.folders' activeClass='selected' class="option" tagName="li"}}Spaces{{/link-to}}
|
||||||
{{#link-to 'customize.users' activeClass='selected' class="option" tagName="li"}}Users{{/link-to}}
|
{{#link-to 'customize.users' activeClass='selected' class="option" tagName="li"}}Users{{/link-to}}
|
||||||
|
{{#if session.isGlobalAdmin}}
|
||||||
|
{{#link-to 'customize.global' activeClass='selected' class="option" tagName="li"}}Global{{/link-to}}
|
||||||
|
{{/if}}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{{/layout/zone-sidebar}}
|
{{/layout/zone-sidebar}}
|
||||||
|
|
|
@ -50,6 +50,9 @@ export default Router.map(function () {
|
||||||
});
|
});
|
||||||
this.route('folders', {
|
this.route('folders', {
|
||||||
path: 'folders'
|
path: 'folders'
|
||||||
|
});
|
||||||
|
this.route('global', {
|
||||||
|
path: 'global'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
44
app/app/services/global.js
Normal file
44
app/app/services/global.js
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
|
//
|
||||||
|
// This software (Documize Community Edition) is licensed under
|
||||||
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
|
//
|
||||||
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
|
// by contacting <sales@documize.com>.
|
||||||
|
//
|
||||||
|
// https://documize.com
|
||||||
|
|
||||||
|
import Ember from 'ember';
|
||||||
|
|
||||||
|
const {
|
||||||
|
inject: { service }
|
||||||
|
} = Ember;
|
||||||
|
|
||||||
|
export default Ember.Service.extend({
|
||||||
|
sessionService: service('session'),
|
||||||
|
ajax: service(),
|
||||||
|
appMeta: service(),
|
||||||
|
store: service(),
|
||||||
|
|
||||||
|
// Returns global configuration.
|
||||||
|
getConfig() {
|
||||||
|
if(this.get('sessionService.isGlobalAdmin')) {
|
||||||
|
return this.get('ajax').request(`global`, {
|
||||||
|
method: 'GET'
|
||||||
|
}).then((response) => {
|
||||||
|
return response;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Saves global configuration.
|
||||||
|
saveConfig(config) {
|
||||||
|
if(this.get('sessionService.isGlobalAdmin')) {
|
||||||
|
return this.get('ajax').request(`global`, {
|
||||||
|
method: 'PUT',
|
||||||
|
data: JSON.stringify(config)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
|
@ -35,6 +35,10 @@ export default SimpleAuthSession.extend({
|
||||||
let data = this.get('user');
|
let data = this.get('user');
|
||||||
return data.get('editor');
|
return data.get('editor');
|
||||||
}),
|
}),
|
||||||
|
isGlobalAdmin: computed('user', function () {
|
||||||
|
let data = this.get('user');
|
||||||
|
return data.get('global');
|
||||||
|
}),
|
||||||
|
|
||||||
init: function () {
|
init: function () {
|
||||||
this.set('isMac', is.mac());
|
this.set('isMac', is.mac());
|
||||||
|
|
|
@ -7,18 +7,18 @@
|
||||||
<div class="input-control">
|
<div class="input-control">
|
||||||
<label>Title</label>
|
<label>Title</label>
|
||||||
<div class="tip">Describe the title of this Documize instance</div>
|
<div class="tip">Describe the title of this Documize instance</div>
|
||||||
{{focus-input id="siteTitle" type="text" value=model.title class=(if hasTitleInputError 'error')}}
|
{{focus-input id="siteTitle" type="text" value=model.general.title class=(if hasTitleInputError 'error')}}
|
||||||
</div>
|
</div>
|
||||||
<div class="input-control">
|
<div class="input-control">
|
||||||
<label>Message</label>
|
<label>Message</label>
|
||||||
<div class="tip">Describe the purpose of this Documize instance</div>
|
<div class="tip">Describe the purpose of this Documize instance</div>
|
||||||
{{textarea id="siteMessage" rows="3" value=model.message class=(if hasMessageInputError 'error')}}
|
{{textarea id="siteMessage" rows="3" value=model.general.message class=(if hasMessageInputError 'error')}}
|
||||||
</div>
|
</div>
|
||||||
<div class="input-control">
|
<div class="input-control">
|
||||||
<label>Anonymous Access</label>
|
<label>Anonymous Access</label>
|
||||||
<div class="tip">Content within "Everyone" will be made available to anonymous users</div>
|
<div class="tip">Content within "Everyone" will be made available to anonymous users</div>
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<input type="checkbox" id="allowAnonymousAccess" checked= {{model.allowAnonymousAccess}} />
|
<input type="checkbox" id="allowAnonymousAccess" checked= {{model.general.allowAnonymousAccess}} />
|
||||||
<label for="allowAnonymousAccess">Allow anyone to access this Documize instance</label>
|
<label for="allowAnonymousAccess">Allow anyone to access this Documize instance</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
34
app/app/templates/components/global-settings.hbs
Normal file
34
app/app/templates/components/global-settings.hbs
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<form>
|
||||||
|
<div class="input-control">
|
||||||
|
<label>Global Settings</label>
|
||||||
|
<div class="tip">Settings applicable for all tenants</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="input-control">
|
||||||
|
<label>SMTP Host</label>
|
||||||
|
<div class="tip">e.g. my.host.com</div>
|
||||||
|
{{focus-input id="smtp-host" type="text" value=model.global.host class=(if SMTPHostEmptyError 'error')}}
|
||||||
|
</div>
|
||||||
|
<div class="input-control">
|
||||||
|
<label>SMTP Host</label>
|
||||||
|
<div class="tip">e.g. 587</div>
|
||||||
|
{{input id="smtp-port" type="text" value=model.global.port class=(if SMTPPortEmptyError 'error')}}
|
||||||
|
</div>
|
||||||
|
<div class="input-control">
|
||||||
|
<label>SMTP Sender</label>
|
||||||
|
<div class="tip">e.g. noreply@documize.com</div>
|
||||||
|
{{input id="smtp-sender" type="text" value=model.global.sender class=(if SMTPSenderEmptyError 'error')}}
|
||||||
|
</div>
|
||||||
|
<div class="input-control">
|
||||||
|
<label>SMTP User ID</label>
|
||||||
|
<div class="tip">Your credentials</div>
|
||||||
|
{{input id="smtp-userid" type="text" value=model.global.userid class=(if SMTPUserIdEmptyError 'error')}}
|
||||||
|
</div>
|
||||||
|
<div class="input-control">
|
||||||
|
<label>SMTP Password</label>
|
||||||
|
<div class="tip">Your credentials</div>
|
||||||
|
{{input id="smtp-password" type="text" value=model.global.password class=(if SMTPPasswordEmptyError 'error')}}
|
||||||
|
</div>
|
||||||
|
<div class="regular-button button-blue" {{ action 'save' }}>save</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
|
@ -199,6 +199,7 @@ func Authorize(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
|
||||||
context.OrgName = org.Title
|
context.OrgName = org.Title
|
||||||
context.Administrator = false
|
context.Administrator = false
|
||||||
context.Editor = false
|
context.Editor = false
|
||||||
|
context.Global = false
|
||||||
|
|
||||||
// Fetch user permissions for this org
|
// Fetch user permissions for this org
|
||||||
if context.Authenticated {
|
if context.Authenticated {
|
||||||
|
@ -211,6 +212,7 @@ func Authorize(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
|
||||||
|
|
||||||
context.Administrator = user.Admin
|
context.Administrator = user.Admin
|
||||||
context.Editor = user.Editor
|
context.Editor = user.Editor
|
||||||
|
context.Global = user.Global
|
||||||
}
|
}
|
||||||
|
|
||||||
request.SetContext(r, context)
|
request.SetContext(r, context)
|
||||||
|
|
81
core/api/endpoint/global_endpoint.go
Normal file
81
core/api/endpoint/global_endpoint.go
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
|
//
|
||||||
|
// This software (Documize Community Edition) is licensed under
|
||||||
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
|
//
|
||||||
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
|
// by contacting <sales@documize.com>.
|
||||||
|
//
|
||||||
|
// https://documize.com
|
||||||
|
|
||||||
|
package endpoint
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/documize/community/core/api/request"
|
||||||
|
"github.com/documize/community/core/api/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetGlobalConfig returns installation-wide settings
|
||||||
|
func GetGlobalConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
|
method := "GetGlobalConfig"
|
||||||
|
p := request.GetPersister(r)
|
||||||
|
|
||||||
|
if !p.Context.Global {
|
||||||
|
writeForbiddenError(w)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// SMTP settings
|
||||||
|
config := request.ConfigString("SMTP", "")
|
||||||
|
|
||||||
|
// marshall as JSON
|
||||||
|
var y map[string]interface{}
|
||||||
|
json.Unmarshal([]byte(config), &y)
|
||||||
|
|
||||||
|
json, err := json.Marshal(y)
|
||||||
|
if err != nil {
|
||||||
|
writeJSONMarshalError(w, method, "GetGlobalConfig", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
util.WriteSuccessBytes(w, json)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveGlobalConfig persists global configuration.
|
||||||
|
func SaveGlobalConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
|
method := "SaveGlobalConfig"
|
||||||
|
p := request.GetPersister(r)
|
||||||
|
|
||||||
|
if !p.Context.Global {
|
||||||
|
writeForbiddenError(w)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
defer r.Body.Close()
|
||||||
|
|
||||||
|
body, err := ioutil.ReadAll(r.Body)
|
||||||
|
if err != nil {
|
||||||
|
writePayloadError(w, method, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var config string
|
||||||
|
config = string(body)
|
||||||
|
|
||||||
|
tx, err := request.Db.Beginx()
|
||||||
|
if err != nil {
|
||||||
|
writeTransactionError(w, method, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
p.Context.Transaction = tx
|
||||||
|
|
||||||
|
request.ConfigSet("SMTP", config)
|
||||||
|
|
||||||
|
util.WriteSuccessEmptyJSON(w)
|
||||||
|
}
|
|
@ -212,6 +212,10 @@ func init() {
|
||||||
log.IfErr(Add(RoutePrefixPrivate, "sections", []string{"POST", "OPTIONS"}, nil, RunSectionCommand))
|
log.IfErr(Add(RoutePrefixPrivate, "sections", []string{"POST", "OPTIONS"}, nil, RunSectionCommand))
|
||||||
log.IfErr(Add(RoutePrefixPrivate, "sections/refresh", []string{"GET", "OPTIONS"}, nil, RefreshSections))
|
log.IfErr(Add(RoutePrefixPrivate, "sections/refresh", []string{"GET", "OPTIONS"}, nil, RefreshSections))
|
||||||
|
|
||||||
|
// Global installation-wide config
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "global", []string{"GET", "OPTIONS"}, nil, GetGlobalConfig))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "global", []string{"PUT", "OPTIONS"}, nil, SaveGlobalConfig))
|
||||||
|
|
||||||
// **** configure single page app handler.
|
// **** configure single page app handler.
|
||||||
|
|
||||||
log.IfErr(Add(RoutePrefixRoot, "robots.txt", []string{"GET", "OPTIONS"}, nil, GetRobots))
|
log.IfErr(Add(RoutePrefixRoot, "robots.txt", []string{"GET", "OPTIONS"}, nil, GetRobots))
|
||||||
|
|
|
@ -45,6 +45,7 @@ type User struct {
|
||||||
Active bool `json:"active"`
|
Active bool `json:"active"`
|
||||||
Editor bool `json:"editor"`
|
Editor bool `json:"editor"`
|
||||||
Admin bool `json:"admin"`
|
Admin bool `json:"admin"`
|
||||||
|
Global bool `json:"global"`
|
||||||
Password string `json:"-"`
|
Password string `json:"-"`
|
||||||
Salt string `json:"-"`
|
Salt string `json:"-"`
|
||||||
Reset string `json:"-"`
|
Reset string `json:"-"`
|
||||||
|
|
|
@ -32,6 +32,7 @@ type Context struct {
|
||||||
Administrator bool
|
Administrator bool
|
||||||
Guest bool
|
Guest bool
|
||||||
Editor bool
|
Editor bool
|
||||||
|
Global bool
|
||||||
UserID string
|
UserID string
|
||||||
OrgID string
|
OrgID string
|
||||||
OrgName string
|
OrgName string
|
||||||
|
|
|
@ -55,7 +55,7 @@ func (p *Persister) AddUser(user entity.User) (err error) {
|
||||||
|
|
||||||
// GetUser returns the user record for the given id.
|
// GetUser returns the user record for the given id.
|
||||||
func (p *Persister) GetUser(id string) (user entity.User, err error) {
|
func (p *Persister) GetUser(id string) (user entity.User, err error) {
|
||||||
stmt, err := Db.Preparex("SELECT id, refid, firstname, lastname, email, initials, password, salt, reset, active, created, revised FROM user WHERE refid=?")
|
stmt, err := Db.Preparex("SELECT id, refid, firstname, lastname, email, initials, global, password, salt, reset, active, created, revised FROM user WHERE refid=?")
|
||||||
defer utility.Close(stmt)
|
defer utility.Close(stmt)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -77,7 +77,7 @@ func (p *Persister) GetUser(id string) (user entity.User, err error) {
|
||||||
func (p *Persister) GetUserByEmail(email string) (user entity.User, err error) {
|
func (p *Persister) GetUserByEmail(email string) (user entity.User, err error) {
|
||||||
email = strings.TrimSpace(strings.ToLower(email))
|
email = strings.TrimSpace(strings.ToLower(email))
|
||||||
|
|
||||||
stmt, err := Db.Preparex("SELECT id, refid, firstname, lastname, email, initials, password, salt, reset, active, created, revised FROM user WHERE TRIM(LOWER(email))=?")
|
stmt, err := Db.Preparex("SELECT id, refid, firstname, lastname, email, initials, global, password, salt, reset, active, created, revised FROM user WHERE TRIM(LOWER(email))=?")
|
||||||
defer utility.Close(stmt)
|
defer utility.Close(stmt)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -99,7 +99,7 @@ func (p *Persister) GetUserByEmail(email string) (user entity.User, err error) {
|
||||||
func (p *Persister) GetUserByDomain(domain, email string) (user entity.User, err error) {
|
func (p *Persister) GetUserByDomain(domain, email string) (user entity.User, err error) {
|
||||||
email = strings.TrimSpace(strings.ToLower(email))
|
email = strings.TrimSpace(strings.ToLower(email))
|
||||||
|
|
||||||
stmt, err := Db.Preparex("SELECT u.id, u.refid, u.firstname, u.lastname, u.email, u.initials, u.password, u.salt, u.reset, u.active, u.created, u.revised FROM user u, account a, organization o WHERE TRIM(LOWER(u.email))=? AND u.refid=a.userid AND a.orgid=o.refid AND TRIM(LOWER(o.domain))=?")
|
stmt, err := Db.Preparex("SELECT u.id, u.refid, u.firstname, u.lastname, u.email, u.initials, u.global, u.password, u.salt, u.reset, u.active, u.created, u.revised FROM user u, account a, organization o WHERE TRIM(LOWER(u.email))=? AND u.refid=a.userid AND a.orgid=o.refid AND TRIM(LOWER(o.domain))=?")
|
||||||
defer utility.Close(stmt)
|
defer utility.Close(stmt)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -119,7 +119,7 @@ func (p *Persister) GetUserByDomain(domain, email string) (user entity.User, err
|
||||||
|
|
||||||
// GetUserByToken returns a user record given a reset token value.
|
// GetUserByToken returns a user record given a reset token value.
|
||||||
func (p *Persister) GetUserByToken(token string) (user entity.User, err error) {
|
func (p *Persister) GetUserByToken(token string) (user entity.User, err error) {
|
||||||
stmt, err := Db.Preparex("SELECT id, refid, firstname, lastname, email, initials, password, salt, reset, active, created, revised FROM user WHERE reset=?")
|
stmt, err := Db.Preparex("SELECT id, refid, firstname, lastname, email, initials, global, password, salt, reset, active, created, revised FROM user WHERE reset=?")
|
||||||
defer utility.Close(stmt)
|
defer utility.Close(stmt)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -141,7 +141,7 @@ func (p *Persister) GetUserByToken(token string) (user entity.User, err error) {
|
||||||
// This occurs when we you share a folder with a new user and they have to complete
|
// This occurs when we you share a folder with a new user and they have to complete
|
||||||
// the onboarding process.
|
// the onboarding process.
|
||||||
func (p *Persister) GetUserBySerial(serial string) (user entity.User, err error) {
|
func (p *Persister) GetUserBySerial(serial string) (user entity.User, err error) {
|
||||||
stmt, err := Db.Preparex("SELECT id, refid, firstname, lastname, email, initials, password, salt, reset, active, created, revised FROM user WHERE salt=?")
|
stmt, err := Db.Preparex("SELECT id, refid, firstname, lastname, email, initials, global, password, salt, reset, active, created, revised FROM user WHERE salt=?")
|
||||||
defer utility.Close(stmt)
|
defer utility.Close(stmt)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -164,7 +164,7 @@ func setupAccount(completion onboardRequest, serial string) (err error) {
|
||||||
|
|
||||||
userID := util.UniqueID()
|
userID := util.UniqueID()
|
||||||
|
|
||||||
sql = fmt.Sprintf("insert into user (refid, firstname, lastname, email, initials, salt, password) values (\"%s\",\"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\")",
|
sql = fmt.Sprintf("insert into user (refid, firstname, lastname, email, initials, salt, password, global) values (\"%s\",\"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", 1)",
|
||||||
userID, completion.Firstname, completion.Lastname, completion.Email, utility.MakeInitials(completion.Firstname, completion.Lastname), salt, password)
|
userID, completion.Firstname, completion.Lastname, completion.Email, utility.MakeInitials(completion.Firstname, completion.Lastname), salt, password)
|
||||||
_, err = runSQL(sql)
|
_, err = runSQL(sql)
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ CREATE TABLE IF NOT EXISTS `user` (
|
||||||
`lastname` NVARCHAR(500) NOT NULL,
|
`lastname` NVARCHAR(500) NOT NULL,
|
||||||
`email` NVARCHAR(250) NOT NULL UNIQUE,
|
`email` NVARCHAR(250) NOT NULL UNIQUE,
|
||||||
`initials` NVARCHAR(10) NOT NULL DEFAULT "",
|
`initials` NVARCHAR(10) NOT NULL DEFAULT "",
|
||||||
|
`global` BOOL NOT NULL DEFAULT 0,
|
||||||
`password` NVARCHAR(500) NOT NULL DEFAULT "",
|
`password` NVARCHAR(500) NOT NULL DEFAULT "",
|
||||||
`salt` NVARCHAR(100) NOT NULL DEFAULT "",
|
`salt` NVARCHAR(100) NOT NULL DEFAULT "",
|
||||||
`reset` NVARCHAR(100) NOT NULL DEFAULT "",
|
`reset` NVARCHAR(100) NOT NULL DEFAULT "",
|
||||||
|
|
2
core/database/scripts/autobuild/db_00003.sql
Normal file
2
core/database/scripts/autobuild/db_00003.sql
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
/* community edition */
|
||||||
|
ALTER TABLE user ADD COLUMN `global` BOOL NOT NULL DEFAULT 0 AFTER `initials`;
|
|
@ -26,8 +26,8 @@ type ProdInfo struct {
|
||||||
// Product returns product edition details
|
// Product returns product edition details
|
||||||
func Product() (p ProdInfo) {
|
func Product() (p ProdInfo) {
|
||||||
p.Major = "0"
|
p.Major = "0"
|
||||||
p.Minor = "26"
|
p.Minor = "27"
|
||||||
p.Patch = "1"
|
p.Patch = "0"
|
||||||
p.Version = fmt.Sprintf("%s.%s.%s", p.Major, p.Minor, p.Patch)
|
p.Version = fmt.Sprintf("%s.%s.%s", p.Major, p.Minor, p.Patch)
|
||||||
p.Edition = "Community"
|
p.Edition = "Community"
|
||||||
p.Title = fmt.Sprintf("%s Edition", p.Edition)
|
p.Title = fmt.Sprintf("%s Edition", p.Edition)
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue