diff --git a/domain/meta/endpoint.go b/domain/meta/endpoint.go index 4c5c9b57..a48aba89 100644 --- a/domain/meta/endpoint.go +++ b/domain/meta/endpoint.go @@ -27,6 +27,7 @@ import ( "github.com/documize/community/domain/auth" "github.com/documize/community/domain/organization" indexer "github.com/documize/community/domain/search" + "github.com/documize/community/domain/setting" "github.com/documize/community/domain/store" "github.com/documize/community/model/doc" "github.com/documize/community/model/org" @@ -67,6 +68,13 @@ func (h *Handler) Meta(w http.ResponseWriter, r *http.Request) { data.Storage = h.Runtime.StoreProvider.Type() data.Location = h.Runtime.Flags.Location // reserved + // Is product setup complete? SMTP in this case. + data.Configured = true + cfg := setting.GetSMTPConfig(h.Store) + if len(cfg.Host) == 0 { + data.Configured = false + } + // Strip secrets data.AuthConfig = auth.StripAuthSecrets(h.Runtime, org.AuthProvider, org.AuthConfig) diff --git a/domain/setting/endpoint.go b/domain/setting/endpoint.go index ddb7ae1f..b07e1f4a 100644 --- a/domain/setting/endpoint.go +++ b/domain/setting/endpoint.go @@ -48,7 +48,6 @@ func (h *Handler) SMTP(w http.ResponseWriter, r *http.Request) { var y map[string]interface{} json.Unmarshal([]byte(config), &y) - j, err := json.Marshal(y) if err != nil { response.WriteBadRequestError(w, method, err.Error()) diff --git a/gui/app/components/customize/smtp-settings.js b/gui/app/components/customize/smtp-settings.js index 080ff383..fcf2f7e3 100644 --- a/gui/app/components/customize/smtp-settings.js +++ b/gui/app/components/customize/smtp-settings.js @@ -11,10 +11,12 @@ import $ from 'jquery'; import { empty } from '@ember/object/computed'; +import { inject as service } from '@ember/service'; import Notifier from '../../mixins/notifier'; import Component from '@ember/component'; export default Component.extend(Notifier, { + appMeta: service(), SMTPHostEmptyError: empty('model.smtp.host'), SMTPPortEmptyError: empty('model.smtp.port'), SMTPSenderEmptyError: empty('model.smtp.sender'), @@ -55,6 +57,8 @@ export default Component.extend(Notifier, { this.set('buttonText', 'Save & Test'); this.set('testSMTP', result); + this.set('appMeta.configured', true); + if (result.success) { this.notifySuccess(result.message); } else { diff --git a/gui/app/components/layout/master-navigation.js b/gui/app/components/layout/master-navigation.js index 6510db86..7142e184 100644 --- a/gui/app/components/layout/master-navigation.js +++ b/gui/app/components/layout/master-navigation.js @@ -162,6 +162,14 @@ export default Component.extend(Modals, { } this.get('router').transitionTo('customize.billing'); + }, + + onConfigured() { + if (!this.get('session.isAdmin')) { + return; + } + + this.get('router').transitionTo('customize.smtp'); } } }); diff --git a/gui/app/services/app-meta.js b/gui/app/services/app-meta.js index 889efa79..8986a5e9 100644 --- a/gui/app/services/app-meta.js +++ b/gui/app/services/app-meta.js @@ -34,6 +34,7 @@ export default Service.extend({ allowAnonymousAccess: false, authProvider: null, authConfig: null, + configured: true, setupMode: false, secureMode: false, maxTags: 3, diff --git a/gui/app/templates/components/layout/master-navigation.hbs b/gui/app/templates/components/layout/master-navigation.hbs index db6d9609..ed9ddf16 100644 --- a/gui/app/templates/components/layout/master-navigation.hbs +++ b/gui/app/templates/components/layout/master-navigation.hbs @@ -40,7 +40,13 @@ {{#unless appMeta.valid}}