updated CHANGELOG.md

This commit is contained in:
marvzhang
2019-12-20 13:13:05 +08:00
parent c5b0011dab
commit 7eaad2cb7c
2 changed files with 8 additions and 1 deletions

View File

@@ -3,6 +3,7 @@
- **Disclaimer**. Added page for Disclaimer.
- **Call API to fetch version**. [#371](https://github.com/crawlab-team/crawlab/issues/371)
- **Configure to allow user registration**. [#346](https://github.com/crawlab-team/crawlab/issues/346)
- **Allow adding new users**.
### Bug Fixes
- **"mongodb no reachable" error**. [#373](https://github.com/crawlab-team/crawlab/issues/373)

View File

@@ -21,6 +21,7 @@ type UserListRequestData struct {
type UserRequestData struct {
Username string `json:"username"`
Password string `json:"password"`
Role string `json:"role"`
}
func GetUser(c *gin.Context) {
@@ -88,11 +89,16 @@ func PutUser(c *gin.Context) {
return
}
// 默认为正常用户
if reqData.Role == "" {
reqData.Role = constants.RoleNormal
}
// 添加用户
user := model.User{
Username: strings.ToLower(reqData.Username),
Password: utils.EncryptPassword(reqData.Password),
Role: constants.RoleNormal,
Role: reqData.Role,
}
if err := user.Add(); err != nil {
HandleError(http.StatusInternalServerError, c, err)