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

improved setup wizard redirection

This commit is contained in:
Harvey Kandola 2017-08-29 17:55:41 +01:00
parent 8081b60146
commit d3512b499a
15 changed files with 670 additions and 661 deletions

View file

@ -8,7 +8,7 @@ The mission is to bring software dev inspired features (refactoring, testing, li
## Latest version ## Latest version
v1.53.1 v1.53.2
## OS Support ## OS Support

View file

@ -18,6 +18,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/documize/community/core/api/plugins"
"github.com/documize/community/core/env" "github.com/documize/community/core/env"
"github.com/documize/community/core/secrets" "github.com/documize/community/core/secrets"
"github.com/documize/community/core/stringutil" "github.com/documize/community/core/stringutil"
@ -32,8 +33,8 @@ type Handler struct {
Store *domain.Store Store *domain.Store
} }
// Create the tables in a blank database // Setup the tables in a blank database
func (h *Handler) Create(w http.ResponseWriter, r *http.Request) { func (h *Handler) Setup(w http.ResponseWriter, r *http.Request) {
defer func() { defer func() {
target := "/setup" target := "/setup"
status := http.StatusBadRequest status := http.StatusBadRequest
@ -45,7 +46,7 @@ func (h *Handler) Create(w http.ResponseWriter, r *http.Request) {
req, err := http.NewRequest("GET", target, nil) req, err := http.NewRequest("GET", target, nil)
if err != nil { if err != nil {
h.Runtime.Log.Error("database.Create()'s error in defer ", err) h.Runtime.Log.Error("database.Setup error in defer ", err)
} }
http.Redirect(w, req, target, status) http.Redirect(w, req, target, status)
@ -53,7 +54,7 @@ func (h *Handler) Create(w http.ResponseWriter, r *http.Request) {
err := r.ParseForm() err := r.ParseForm()
if err != nil { if err != nil {
h.Runtime.Log.Error("database.Create()'s r.ParseForm()", err) h.Runtime.Log.Error("database.Setup r.ParseForm()", err)
return return
} }
@ -61,7 +62,7 @@ func (h *Handler) Create(w http.ResponseWriter, r *http.Request) {
dbhash := r.Form.Get("dbhash") dbhash := r.Form.Get("dbhash")
if dbname != web.SiteInfo.DBname || dbhash != web.SiteInfo.DBhash { if dbname != web.SiteInfo.DBname || dbhash != web.SiteInfo.DBhash {
h.Runtime.Log.Error("database.Create()'s security credentials error ", errors.New("bad db name or validation code")) h.Runtime.Log.Error("database.Setup security credentials error ", errors.New("bad db name or validation code"))
return return
} }
@ -84,22 +85,27 @@ func (h *Handler) Create(w http.ResponseWriter, r *http.Request) {
details.Password == "" || details.Password == "" ||
details.Firstname == "" || details.Firstname == "" ||
details.Lastname == "" { details.Lastname == "" {
h.Runtime.Log.Error("database.Create() error ", errors.New("required field in database set-up form blank")) h.Runtime.Log.Error("database.Setup error ", errors.New("required field in database set-up form blank"))
return return
} }
if err = Migrate(h.Runtime, false /* no tables exist yet */); err != nil { if err = Migrate(h.Runtime, false /* no tables exist yet */); err != nil {
h.Runtime.Log.Error("database.Create()", err) h.Runtime.Log.Error("database.Setup migrate", err)
return return
} }
err = setupAccount(h.Runtime, details, secrets.GenerateSalt()) err = setupAccount(h.Runtime, details, secrets.GenerateSalt())
if err != nil { if err != nil {
h.Runtime.Log.Error("database.Create()", err) h.Runtime.Log.Error("database.Setup setup account ", err)
return return
} }
h.Runtime.Flags.SiteMode = env.SiteModeNormal h.Runtime.Flags.SiteMode = env.SiteModeNormal
err = plugins.Setup(h.Store)
if err != nil {
h.Runtime.Log.Error("database.Setup plugin setup failed", err)
}
} }
// The result of completing the onboarding process. // The result of completing the onboarding process.

View file

@ -268,6 +268,7 @@ func getStatements(bytes []byte) []string {
stripped := regexp.MustCompile("(?s)--.*?\n|/\\*.*?\\*/").ReplaceAll(bytes, []byte("\n")) stripped := regexp.MustCompile("(?s)--.*?\n|/\\*.*?\\*/").ReplaceAll(bytes, []byte("\n"))
sqls := strings.Split(string(stripped), ";") sqls := strings.Split(string(stripped), ";")
ret := make([]string, 0, len(sqls)) ret := make([]string, 0, len(sqls))
for _, v := range sqls { for _, v := range sqls {
trimmed := strings.TrimSpace(v) trimmed := strings.TrimSpace(v)
if len(trimmed) > 0 && if len(trimmed) > 0 &&
@ -275,5 +276,6 @@ func getStatements(bytes []byte) []string {
ret = append(ret, trimmed+";") ret = append(ret, trimmed+";")
} }
} }
return ret return ret
} }

View file

@ -175,8 +175,6 @@ func (h *Handler) Sitemap(w http.ResponseWriter, r *http.Request) {
response.WriteBytes(w, buffer.Bytes()) response.WriteBytes(w, buffer.Bytes())
} }
// sitemapItem provides a means to teleport somewhere else for free.
// What did you think it did?
type sitemapItem struct { type sitemapItem struct {
URL string URL string
Date string Date string

View file

@ -78,7 +78,7 @@ func (s Scope) GetOrganization(ctx domain.RequestContext, id string) (org org.Or
// GetOrganizationByDomain returns the organization matching a given URL subdomain. // GetOrganizationByDomain returns the organization matching a given URL subdomain.
// No context is required because user might no be authenticated yet. // No context is required because user might no be authenticated yet.
func (s Scope) GetOrganizationByDomain(subdomain string) (org org.Organization, err error) { func (s Scope) GetOrganizationByDomain(subdomain string) (o org.Organization, err error) {
err = nil err = nil
subdomain = strings.TrimSpace(strings.ToLower(subdomain)) subdomain = strings.TrimSpace(strings.ToLower(subdomain))
@ -93,8 +93,7 @@ func (s Scope) GetOrganizationByDomain(subdomain string) (org org.Organization,
return return
} }
err = stmt.Get(&org, subdomain) err = stmt.Get(&o, subdomain)
if err != nil && err != sql.ErrNoRows { if err != nil && err != sql.ErrNoRows {
err = errors.Wrap(err, fmt.Sprintf("unable to execute select for subdomain %s", subdomain)) err = errors.Wrap(err, fmt.Sprintf("unable to execute select for subdomain %s", subdomain))
return return

View file

@ -38,7 +38,7 @@ func main() {
rt.Product = env.ProdInfo{} rt.Product = env.ProdInfo{}
rt.Product.Major = "1" rt.Product.Major = "1"
rt.Product.Minor = "53" rt.Product.Minor = "53"
rt.Product.Patch = "1" rt.Product.Patch = "2"
rt.Product.Version = fmt.Sprintf("%s.%s.%s", rt.Product.Major, rt.Product.Minor, rt.Product.Patch) rt.Product.Version = fmt.Sprintf("%s.%s.%s", rt.Product.Major, rt.Product.Minor, rt.Product.Patch)
rt.Product.Edition = "Community" rt.Product.Edition = "Community"
rt.Product.Title = fmt.Sprintf("%s Edition", rt.Product.Edition) rt.Product.Title = fmt.Sprintf("%s Edition", rt.Product.Edition)

File diff suppressed because one or more lines are too long

View file

@ -12,14 +12,23 @@
import Ember from 'ember'; import Ember from 'ember';
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
const {
inject: { service }
} = Ember;
export default Ember.Route.extend(AuthenticatedRouteMixin, { export default Ember.Route.extend(AuthenticatedRouteMixin, {
folderService: Ember.inject.service('folder'), appMeta: service(),
folderService: service('folder'),
localStorage: service(),
beforeModel() {
if (this.get('appMeta.setupMode')) {
this.get('localStorage').clearAll();
this.transitionTo('setup');
}
},
model() { model() {
// if (this.get('appMeta.setupMode')) {
// localStorage.clearAll();
// return;
// }
return this.get('folderService').getAll(); return this.get('folderService').getAll();
} }
}); });

View file

@ -1,11 +1,11 @@
// 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
@ -36,6 +36,6 @@ export default Ember.Route.extend({
}, },
activate() { activate() {
document.title = "Setup Documize database '" + document.head.querySelector("[property=dbname]").content + "'"; document.title = "Documize Setup";
} }
}); });

View file

@ -31,19 +31,15 @@ export default Ember.Route.extend(ApplicationRouteMixin, TooltipMixin, {
return this.get('appMeta').boot(transition.targetName, window.location.href).then(data => { return this.get('appMeta').boot(transition.targetName, window.location.href).then(data => {
if (sa !== "authenticator:documize" && sa !== "authenticator:keycloak" && data.allowAnonymousAccess) { if (sa !== "authenticator:documize" && sa !== "authenticator:keycloak" && data.allowAnonymousAccess) {
if (!this.get('appMeta.setupMode')) { if (!this.get('appMeta.setupMode') && !this.get('appMeta.secureMode')) {
return this.get('session').authenticate('authenticator:anonymous', data); return this.get('session').authenticate('authenticator:anonymous', data);
// } else {
// this.get('localStorage').clearAll();
} }
} }
return;
}); });
}, },
sessionAuthenticated() { sessionAuthenticated() {
if (this.get('appMeta.setupMode')) { if (this.get('appMeta.setupMode') || this.get('appMeta.secureMode')) {
this.get('localStorage').clearAll(); this.get('localStorage').clearAll();
return; return;
} }

View file

@ -36,6 +36,7 @@ export default Ember.Service.extend({
authProvider: constants.AuthProvider.Documize, authProvider: constants.AuthProvider.Documize,
authConfig: null, authConfig: null,
setupMode: false, setupMode: false,
secureMode: false,
invalidLicense() { invalidLicense() {
return this.valid === false; return this.valid === false;
@ -68,7 +69,7 @@ export default Ember.Service.extend({
this.setProperties({ this.setProperties({
title: htmlSafe("Secure document viewing"), title: htmlSafe("Secure document viewing"),
allowAnonymousAccess: true, allowAnonymousAccess: true,
setupMode: true secureMode: true
}); });
this.get('localStorage').clearAll(); this.get('localStorage').clearAll();

View file

@ -2,7 +2,7 @@
<div class="form-bordered"> <div class="form-bordered">
<div class="form-header"> <div class="form-header">
<div class="title">Let's setup Documize</div> <div class="title">Let's setup Documize</div>
<div class="tip">Database name is <em>{{model.dbname}}</em></div> <div class="tip">Database: <b>{{model.dbname}}</b></div>
</div> </div>
<div class="input-control input-transparent"> <div class="input-control input-transparent">
<label>Team</label> <label>Team</label>

View file

@ -1,6 +1,6 @@
{ {
"name": "documize", "name": "documize",
"version": "1.53.1", "version": "1.53.2",
"description": "The Document IDE", "description": "The Document IDE",
"private": true, "private": true,
"repository": "", "repository": "",

View file

@ -1,16 +1,16 @@
{ {
"community": "community":
{ {
"version": "1.53.1", "version": "1.53.2",
"major": 1, "major": 1,
"minor": 53, "minor": 53,
"patch": 1 "patch": 2
}, },
"enterprise": "enterprise":
{ {
"version": "1.55.1", "version": "1.55.2",
"major": 1, "major": 1,
"minor": 55, "minor": 55,
"patch": 1 "patch": 2
} }
} }

View file

@ -14,7 +14,6 @@ package server
import ( import (
"fmt" "fmt"
"net/http" "net/http"
"os"
"strings" "strings"
"github.com/codegangsta/negroni" "github.com/codegangsta/negroni"
@ -38,16 +37,15 @@ func Start(rt *env.Runtime, s *domain.Store, ready chan struct{}) {
case env.SiteModeOffline: case env.SiteModeOffline:
rt.Log.Info("Serving OFFLINE web server") rt.Log.Info("Serving OFFLINE web server")
case env.SiteModeSetup: case env.SiteModeSetup:
dbHandler := database.Handler{Runtime: rt, Store: s}
routing.Add(rt, routing.RoutePrefixPrivate, "setup", []string{"POST", "OPTIONS"}, nil, dbHandler.Create)
rt.Log.Info("Serving SETUP web server") rt.Log.Info("Serving SETUP web server")
dbHandler := database.Handler{Runtime: rt, Store: s}
routing.Add(rt, routing.RoutePrefixPrivate, "setup", []string{"POST", "OPTIONS"}, nil, dbHandler.Setup)
case env.SiteModeBadDB: case env.SiteModeBadDB:
rt.Log.Info("Serving BAD DATABASE web server") rt.Log.Info("Serving BAD DATABASE web server")
default: default:
err := plugins.Setup(s) err := plugins.Setup(s)
if err != nil { if err != nil {
rt.Log.Error("Terminating before running - invalid plugin.json", err) rt.Log.Error("plugin setup failed", err)
os.Exit(1)
} }
rt.Log.Info("Starting web server") rt.Log.Info("Starting web server")
} }