From 7eaad2cb7cb464e50c5007c841c258b4acb62e90 Mon Sep 17 00:00:00 2001 From: marvzhang Date: Fri, 20 Dec 2019 13:13:05 +0800 Subject: [PATCH] updated CHANGELOG.md --- CHANGELOG.md | 1 + backend/routes/user.go | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5509307..671aa8a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/backend/routes/user.go b/backend/routes/user.go index a6d44cae..33b6a958 100644 --- a/backend/routes/user.go +++ b/backend/routes/user.go @@ -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)