@@ -18,6 +18,7 @@ import (
18
18
"strings"
19
19
"time"
20
20
21
+ "github.com/documize/community/core/api/plugins"
21
22
"github.com/documize/community/core/env"
22
23
"github.com/documize/community/core/secrets"
23
24
"github.com/documize/community/core/stringutil"
@@ -32,8 +33,8 @@ type Handler struct {
32
33
Store * domain.Store
33
34
}
34
35
35
- // Create the tables in a blank database
36
- func (h * Handler ) Create (w http.ResponseWriter , r * http.Request ) {
36
+ // Setup the tables in a blank database
37
+ func (h * Handler ) Setup (w http.ResponseWriter , r * http.Request ) {
37
38
defer func () {
38
39
target := "/setup"
39
40
status := http .StatusBadRequest
@@ -45,23 +46,23 @@ func (h *Handler) Create(w http.ResponseWriter, r *http.Request) {
45
46
46
47
req , err := http .NewRequest ("GET" , target , nil )
47
48
if err != nil {
48
- h .Runtime .Log .Error ("database.Create()'s error in defer " , err )
49
+ h .Runtime .Log .Error ("database.Setup error in defer " , err )
49
50
}
50
51
51
52
http .Redirect (w , req , target , status )
52
53
}()
53
54
54
55
err := r .ParseForm ()
55
56
if err != nil {
56
- h .Runtime .Log .Error ("database.Create()'s r.ParseForm()" , err )
57
+ h .Runtime .Log .Error ("database.Setup r.ParseForm()" , err )
57
58
return
58
59
}
59
60
60
61
dbname := r .Form .Get ("dbname" )
61
62
dbhash := r .Form .Get ("dbhash" )
62
63
63
64
if dbname != web .SiteInfo .DBname || dbhash != web .SiteInfo .DBhash {
64
- h .Runtime .Log .Error ("database.Create()'s security credentials error " , errors .New ("bad db name or validation code" ))
65
+ h .Runtime .Log .Error ("database.Setup security credentials error " , errors .New ("bad db name or validation code" ))
65
66
return
66
67
}
67
68
@@ -84,22 +85,27 @@ func (h *Handler) Create(w http.ResponseWriter, r *http.Request) {
84
85
details .Password == "" ||
85
86
details .Firstname == "" ||
86
87
details .Lastname == "" {
87
- h .Runtime .Log .Error ("database.Create() error " , errors .New ("required field in database set-up form blank" ))
88
+ h .Runtime .Log .Error ("database.Setup error " , errors .New ("required field in database set-up form blank" ))
88
89
return
89
90
}
90
91
91
92
if err = Migrate (h .Runtime , false /* no tables exist yet */ ); err != nil {
92
- h .Runtime .Log .Error ("database.Create() " , err )
93
+ h .Runtime .Log .Error ("database.Setup migrate " , err )
93
94
return
94
95
}
95
96
96
97
err = setupAccount (h .Runtime , details , secrets .GenerateSalt ())
97
98
if err != nil {
98
- h .Runtime .Log .Error ("database.Create() " , err )
99
+ h .Runtime .Log .Error ("database.Setup setup account " , err )
99
100
return
100
101
}
101
102
102
103
h .Runtime .Flags .SiteMode = env .SiteModeNormal
104
+
105
+ err = plugins .Setup (h .Store )
106
+ if err != nil {
107
+ h .Runtime .Log .Error ("database.Setup plugin setup failed" , err )
108
+ }
103
109
}
104
110
105
111
// The result of completing the onboarding process.
0 commit comments