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:
parent
8081b60146
commit
d3512b499a
15 changed files with 670 additions and 661 deletions
|
@ -8,7 +8,7 @@ The mission is to bring software dev inspired features (refactoring, testing, li
|
|||
|
||||
## Latest version
|
||||
|
||||
v1.53.1
|
||||
v1.53.2
|
||||
|
||||
## OS Support
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/documize/community/core/api/plugins"
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/core/secrets"
|
||||
"github.com/documize/community/core/stringutil"
|
||||
|
@ -32,8 +33,8 @@ type Handler struct {
|
|||
Store *domain.Store
|
||||
}
|
||||
|
||||
// Create the tables in a blank database
|
||||
func (h *Handler) Create(w http.ResponseWriter, r *http.Request) {
|
||||
// Setup the tables in a blank database
|
||||
func (h *Handler) Setup(w http.ResponseWriter, r *http.Request) {
|
||||
defer func() {
|
||||
target := "/setup"
|
||||
status := http.StatusBadRequest
|
||||
|
@ -45,7 +46,7 @@ func (h *Handler) Create(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
req, err := http.NewRequest("GET", target, 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)
|
||||
|
@ -53,7 +54,7 @@ func (h *Handler) Create(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
err := r.ParseForm()
|
||||
if err != nil {
|
||||
h.Runtime.Log.Error("database.Create()'s r.ParseForm()", err)
|
||||
h.Runtime.Log.Error("database.Setup r.ParseForm()", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -61,7 +62,7 @@ func (h *Handler) Create(w http.ResponseWriter, r *http.Request) {
|
|||
dbhash := r.Form.Get("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
|
||||
}
|
||||
|
||||
|
@ -84,22 +85,27 @@ func (h *Handler) Create(w http.ResponseWriter, r *http.Request) {
|
|||
details.Password == "" ||
|
||||
details.Firstname == "" ||
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
err = setupAccount(h.Runtime, details, secrets.GenerateSalt())
|
||||
if err != nil {
|
||||
h.Runtime.Log.Error("database.Create()", err)
|
||||
h.Runtime.Log.Error("database.Setup setup account ", err)
|
||||
return
|
||||
}
|
||||
|
||||
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.
|
|
@ -268,6 +268,7 @@ func getStatements(bytes []byte) []string {
|
|||
stripped := regexp.MustCompile("(?s)--.*?\n|/\\*.*?\\*/").ReplaceAll(bytes, []byte("\n"))
|
||||
sqls := strings.Split(string(stripped), ";")
|
||||
ret := make([]string, 0, len(sqls))
|
||||
|
||||
for _, v := range sqls {
|
||||
trimmed := strings.TrimSpace(v)
|
||||
if len(trimmed) > 0 &&
|
||||
|
@ -275,5 +276,6 @@ func getStatements(bytes []byte) []string {
|
|||
ret = append(ret, trimmed+";")
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
|
|
@ -175,8 +175,6 @@ func (h *Handler) Sitemap(w http.ResponseWriter, r *http.Request) {
|
|||
response.WriteBytes(w, buffer.Bytes())
|
||||
}
|
||||
|
||||
// sitemapItem provides a means to teleport somewhere else for free.
|
||||
// What did you think it did?
|
||||
type sitemapItem struct {
|
||||
URL string
|
||||
Date string
|
||||
|
|
|
@ -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.
|
||||
// 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
|
||||
subdomain = strings.TrimSpace(strings.ToLower(subdomain))
|
||||
|
||||
|
@ -93,8 +93,7 @@ func (s Scope) GetOrganizationByDomain(subdomain string) (org org.Organization,
|
|||
return
|
||||
}
|
||||
|
||||
err = stmt.Get(&org, subdomain)
|
||||
|
||||
err = stmt.Get(&o, subdomain)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to execute select for subdomain %s", subdomain))
|
||||
return
|
||||
|
|
|
@ -38,7 +38,7 @@ func main() {
|
|||
rt.Product = env.ProdInfo{}
|
||||
rt.Product.Major = "1"
|
||||
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.Edition = "Community"
|
||||
rt.Product.Title = fmt.Sprintf("%s Edition", rt.Product.Edition)
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -12,14 +12,23 @@
|
|||
import Ember from 'ember';
|
||||
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
const {
|
||||
inject: { service }
|
||||
} = Ember;
|
||||
|
||||
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() {
|
||||
// if (this.get('appMeta.setupMode')) {
|
||||
// localStorage.clearAll();
|
||||
// return;
|
||||
// }
|
||||
return this.get('folderService').getAll();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -36,6 +36,6 @@ export default Ember.Route.extend({
|
|||
},
|
||||
|
||||
activate() {
|
||||
document.title = "Setup Documize database '" + document.head.querySelector("[property=dbname]").content + "'";
|
||||
document.title = "Documize Setup";
|
||||
}
|
||||
});
|
|
@ -31,19 +31,15 @@ export default Ember.Route.extend(ApplicationRouteMixin, TooltipMixin, {
|
|||
|
||||
return this.get('appMeta').boot(transition.targetName, window.location.href).then(data => {
|
||||
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);
|
||||
// } else {
|
||||
// this.get('localStorage').clearAll();
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
});
|
||||
},
|
||||
|
||||
sessionAuthenticated() {
|
||||
if (this.get('appMeta.setupMode')) {
|
||||
if (this.get('appMeta.setupMode') || this.get('appMeta.secureMode')) {
|
||||
this.get('localStorage').clearAll();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ export default Ember.Service.extend({
|
|||
authProvider: constants.AuthProvider.Documize,
|
||||
authConfig: null,
|
||||
setupMode: false,
|
||||
secureMode: false,
|
||||
|
||||
invalidLicense() {
|
||||
return this.valid === false;
|
||||
|
@ -68,7 +69,7 @@ export default Ember.Service.extend({
|
|||
this.setProperties({
|
||||
title: htmlSafe("Secure document viewing"),
|
||||
allowAnonymousAccess: true,
|
||||
setupMode: true
|
||||
secureMode: true
|
||||
});
|
||||
|
||||
this.get('localStorage').clearAll();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div class="form-bordered">
|
||||
<div class="form-header">
|
||||
<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 class="input-control input-transparent">
|
||||
<label>Team</label>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "documize",
|
||||
"version": "1.53.1",
|
||||
"version": "1.53.2",
|
||||
"description": "The Document IDE",
|
||||
"private": true,
|
||||
"repository": "",
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
{
|
||||
"community":
|
||||
{
|
||||
"version": "1.53.1",
|
||||
"version": "1.53.2",
|
||||
"major": 1,
|
||||
"minor": 53,
|
||||
"patch": 1
|
||||
"patch": 2
|
||||
},
|
||||
"enterprise":
|
||||
{
|
||||
"version": "1.55.1",
|
||||
"version": "1.55.2",
|
||||
"major": 1,
|
||||
"minor": 55,
|
||||
"patch": 1
|
||||
"patch": 2
|
||||
}
|
||||
}
|
|
@ -14,7 +14,6 @@ package server
|
|||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/codegangsta/negroni"
|
||||
|
@ -38,16 +37,15 @@ func Start(rt *env.Runtime, s *domain.Store, ready chan struct{}) {
|
|||
case env.SiteModeOffline:
|
||||
rt.Log.Info("Serving OFFLINE web server")
|
||||
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")
|
||||
dbHandler := database.Handler{Runtime: rt, Store: s}
|
||||
routing.Add(rt, routing.RoutePrefixPrivate, "setup", []string{"POST", "OPTIONS"}, nil, dbHandler.Setup)
|
||||
case env.SiteModeBadDB:
|
||||
rt.Log.Info("Serving BAD DATABASE web server")
|
||||
default:
|
||||
err := plugins.Setup(s)
|
||||
if err != nil {
|
||||
rt.Log.Error("Terminating before running - invalid plugin.json", err)
|
||||
os.Exit(1)
|
||||
rt.Log.Error("plugin setup failed", err)
|
||||
}
|
||||
rt.Log.Info("Starting web server")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue