Skip to content

Commit 439e786

Browse files
committed
Merge remote-tracking branch 'origin/release/1.7.0'
2 parents fc4959c + b79fb38 commit 439e786

File tree

130 files changed

+1737
-578
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+1737
-578
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: build clean ui
22

3-
VERSION=1.6.0
3+
VERSION=1.7.0
44
BIN=answer
55
DIR_SRC=./cmd/answer
66
DOCKER_CMD=docker

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ To learn more about the project, visit [answer.apache.org](https://answer.apache
2323
### Running with docker
2424

2525
```bash
26-
docker run -d -p 9080:80 -v answer-data:/data --name answer apache/answer:1.6.0
26+
docker run -d -p 9080:80 -v answer-data:/data --name answer apache/answer:1.7.0
2727
```
2828

2929
For more information, see [Installation](https://answer.apache.org/docs/installation).

cmd/command.go

Lines changed: 50 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020
package answercmd
2121

2222
import (
23+
"context"
2324
"fmt"
2425
"os"
2526
"strings"
2627

2728
"github.com/apache/answer/internal/base/conf"
29+
"github.com/apache/answer/internal/base/path"
2830
"github.com/apache/answer/internal/cli"
2931
"github.com/apache/answer/internal/install"
3032
"github.com/apache/answer/internal/migrations"
@@ -53,6 +55,10 @@ var (
5355
i18nSourcePath string
5456
// i18nTargetPath i18n to path
5557
i18nTargetPath string
58+
// resetPasswordEmail user email for password reset
59+
resetPasswordEmail string
60+
// resetPasswordPassword new password for password reset
61+
resetPasswordPassword string
5662
)
5763

5864
func init() {
@@ -76,7 +82,10 @@ func init() {
7682

7783
i18nCmd.Flags().StringVarP(&i18nTargetPath, "target", "t", "", "i18n target path, eg: -t ./i18n/target")
7884

79-
for _, cmd := range []*cobra.Command{initCmd, checkCmd, runCmd, dumpCmd, upgradeCmd, buildCmd, pluginCmd, configCmd, i18nCmd} {
85+
resetPasswordCmd.Flags().StringVarP(&resetPasswordEmail, "email", "e", "", "user email address")
86+
resetPasswordCmd.Flags().StringVarP(&resetPasswordPassword, "password", "p", "", "new password (not recommended, will be recorded in shell history)")
87+
88+
for _, cmd := range []*cobra.Command{initCmd, checkCmd, runCmd, dumpCmd, upgradeCmd, buildCmd, pluginCmd, configCmd, i18nCmd, resetPasswordCmd} {
8089
rootCmd.AddCommand(cmd)
8190
}
8291
}
@@ -96,8 +105,8 @@ To run answer, use:
96105
Short: "Run Answer",
97106
Long: `Start running Answer`,
98107
Run: func(_ *cobra.Command, _ []string) {
99-
cli.FormatAllPath(dataDirPath)
100-
fmt.Println("config file path: ", cli.GetConfigFilePath())
108+
path.FormatAllPath(dataDirPath)
109+
fmt.Println("config file path: ", path.GetConfigFilePath())
101110
fmt.Println("Answer is starting..........................")
102111
runApp()
103112
},
@@ -111,10 +120,10 @@ To run answer, use:
111120
// check config file and database. if config file exists and database is already created, init done
112121
cli.InstallAllInitialEnvironment(dataDirPath)
113122

114-
configFileExist := cli.CheckConfigFile(cli.GetConfigFilePath())
123+
configFileExist := cli.CheckConfigFile(path.GetConfigFilePath())
115124
if configFileExist {
116125
fmt.Println("config file exists, try to read the config...")
117-
c, err := conf.ReadConfig(cli.GetConfigFilePath())
126+
c, err := conf.ReadConfig(path.GetConfigFilePath())
118127
if err != nil {
119128
fmt.Println("read config failed: ", err.Error())
120129
return
@@ -128,7 +137,7 @@ To run answer, use:
128137
}
129138

130139
// start installation server to install
131-
install.Run(cli.GetConfigFilePath())
140+
install.Run(path.GetConfigFilePath())
132141
},
133142
}
134143

@@ -138,9 +147,9 @@ To run answer, use:
138147
Long: `Upgrade Answer to the latest version`,
139148
Run: func(_ *cobra.Command, _ []string) {
140149
log.SetLogger(log.NewStdLogger(os.Stdout))
141-
cli.FormatAllPath(dataDirPath)
150+
path.FormatAllPath(dataDirPath)
142151
cli.InstallI18nBundle(true)
143-
c, err := conf.ReadConfig(cli.GetConfigFilePath())
152+
c, err := conf.ReadConfig(path.GetConfigFilePath())
144153
if err != nil {
145154
fmt.Println("read config failed: ", err.Error())
146155
return
@@ -159,8 +168,8 @@ To run answer, use:
159168
Long: `Back up database into an SQL file`,
160169
Run: func(_ *cobra.Command, _ []string) {
161170
fmt.Println("Answer is backing up data")
162-
cli.FormatAllPath(dataDirPath)
163-
c, err := conf.ReadConfig(cli.GetConfigFilePath())
171+
path.FormatAllPath(dataDirPath)
172+
c, err := conf.ReadConfig(path.GetConfigFilePath())
164173
if err != nil {
165174
fmt.Println("read config failed: ", err.Error())
166175
return
@@ -179,9 +188,9 @@ To run answer, use:
179188
Short: "Check the required environment",
180189
Long: `Check if the current environment meets the startup requirements`,
181190
Run: func(_ *cobra.Command, _ []string) {
182-
cli.FormatAllPath(dataDirPath)
191+
path.FormatAllPath(dataDirPath)
183192
fmt.Println("Start checking the required environment...")
184-
if cli.CheckConfigFile(cli.GetConfigFilePath()) {
193+
if cli.CheckConfigFile(path.GetConfigFilePath()) {
185194
fmt.Println("config file exists [✔]")
186195
} else {
187196
fmt.Println("config file not exists [x]")
@@ -193,7 +202,7 @@ To run answer, use:
193202
fmt.Println("upload directory not exists [x]")
194203
}
195204

196-
c, err := conf.ReadConfig(cli.GetConfigFilePath())
205+
c, err := conf.ReadConfig(path.GetConfigFilePath())
197206
if err != nil {
198207
fmt.Println("read config failed: ", err.Error())
199208
return
@@ -246,9 +255,9 @@ To run answer, use:
246255
Short: "Set some config to default value",
247256
Long: `Set some config to default value`,
248257
Run: func(_ *cobra.Command, _ []string) {
249-
cli.FormatAllPath(dataDirPath)
258+
path.FormatAllPath(dataDirPath)
250259

251-
c, err := conf.ReadConfig(cli.GetConfigFilePath())
260+
c, err := conf.ReadConfig(path.GetConfigFilePath())
252261
if err != nil {
253262
fmt.Println("read config failed: ", err.Error())
254263
return
@@ -297,6 +306,32 @@ To run answer, use:
297306
}
298307
},
299308
}
309+
310+
resetPasswordCmd = &cobra.Command{
311+
Use: "passwd",
312+
Aliases: []string{"password", "reset-password"},
313+
Short: "Reset user password",
314+
Long: "Reset user password by email address.",
315+
Example: ` # Interactive mode (recommended, safest)
316+
answer passwd -C ./answer-data
317+
318+
# Specify email only (will prompt for password securely)
319+
answer passwd -C ./answer-data --email user@example.com
320+
answer passwd -C ./answer-data -e user@example.com
321+
322+
# Specify email and password (NOT recommended, will be recorded in shell history)
323+
answer passwd -C ./answer-data -e user@example.com -p newpassword123`,
324+
Run: func(cmd *cobra.Command, args []string) {
325+
opts := &cli.ResetPasswordOptions{
326+
Email: resetPasswordEmail,
327+
Password: resetPasswordPassword,
328+
}
329+
if err := cli.ResetPassword(context.Background(), dataDirPath, opts); err != nil {
330+
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
331+
os.Exit(1)
332+
}
333+
},
334+
}
300335
)
301336

302337
// Execute adds all child commands to the root command and sets flags appropriately.

cmd/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
"github.com/apache/answer/internal/base/conf"
2929
"github.com/apache/answer/internal/base/constant"
3030
"github.com/apache/answer/internal/base/cron"
31-
"github.com/apache/answer/internal/cli"
31+
"github.com/apache/answer/internal/base/path"
3232
"github.com/apache/answer/internal/schema"
3333
"github.com/gin-gonic/gin"
3434
"github.com/segmentfault/pacman"
@@ -67,7 +67,7 @@ func Main() {
6767
}
6868

6969
func runApp() {
70-
c, err := conf.ReadConfig(cli.GetConfigFilePath())
70+
c, err := conf.ReadConfig(path.GetConfigFilePath())
7171
if err != nil {
7272
panic(err)
7373
}

cmd/wire_gen.go

Lines changed: 7 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/docs.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,3 @@
1-
/*
2-
* Licensed to the Apache Software Foundation (ASF) under one
3-
* or more contributor license agreements. See the NOTICE file
4-
* distributed with this work for additional information
5-
* regarding copyright ownership. The ASF licenses this file
6-
* to you under the Apache License, Version 2.0 (the
7-
* "License"); you may not use this file except in compliance
8-
* with the License. You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing,
13-
* software distributed under the License is distributed on an
14-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15-
* KIND, either express or implied. See the License for the
16-
* specific language governing permissions and limitations
17-
* under the License.
18-
*/
19-
201
// Package docs Code generated by swaggo/swag. DO NOT EDIT
212
package docs
223

docs/swagger.yaml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
1-
# Licensed to the Apache Software Foundation (ASF) under one
2-
# or more contributor license agreements. See the NOTICE file
3-
# distributed with this work for additional information
4-
# regarding copyright ownership. The ASF licenses this file
5-
# to you under the Apache License, Version 2.0 (the
6-
# "License"); you may not use this file except in compliance
7-
# with the License. You may obtain a copy of the License at
8-
#
9-
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
11-
# Unless required by applicable law or agreed to in writing,
12-
# software distributed under the License is distributed on an
13-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14-
# KIND, either express or implied. See the License for the
15-
# specific language governing permissions and limitations
16-
# under the License.
17-
181
basePath: /
192
definitions:
203
constant.NotificationChannelKey:

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ require (
6060
golang.org/x/crypto v0.36.0
6161
golang.org/x/image v0.20.0
6262
golang.org/x/net v0.38.0
63+
golang.org/x/term v0.30.0
6364
golang.org/x/text v0.23.0
6465
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
6566
gopkg.in/yaml.v3 v3.0.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,8 @@ golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXR
785785
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
786786
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
787787
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
788+
golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y=
789+
golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g=
788790
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
789791
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
790792
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=

i18n/af_ZA.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ ui:
684684
caption: People can mention you as "@username".
685685
msg: Username cannot be empty.
686686
msg_range: Username must be 2-30 characters in length.
687-
character: 'Must use the character set "a-z", "0-9", " - . _"'
687+
character: 'Must use the character set "a-z", "0-9", "- . _"'
688688
avatar:
689689
label: Profile Image
690690
gravatar: Gravatar

0 commit comments

Comments
 (0)