mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-28 17:50:56 +01:00
This commit is contained in:
@@ -98,6 +98,11 @@ func PutUser(c *gin.Context) {
|
|||||||
// UserId
|
// UserId
|
||||||
uid := services.GetCurrentUserId(c)
|
uid := services.GetCurrentUserId(c)
|
||||||
|
|
||||||
|
// 空 UserId 处理
|
||||||
|
if uid == "" {
|
||||||
|
uid = bson.ObjectIdHex(constants.ObjectIdNull)
|
||||||
|
}
|
||||||
|
|
||||||
// 添加用户
|
// 添加用户
|
||||||
if err := services.CreateNewUser(reqData.Username, reqData.Password, reqData.Role, reqData.Email, uid); err != nil {
|
if err := services.CreateNewUser(reqData.Username, reqData.Password, reqData.Role, reqData.Email, uid); err != nil {
|
||||||
HandleError(http.StatusInternalServerError, c, err)
|
HandleError(http.StatusInternalServerError, c, err)
|
||||||
|
|||||||
@@ -114,6 +114,9 @@ func CreateNewUser(username string, password string, role string, email string,
|
|||||||
|
|
||||||
func GetCurrentUser(c *gin.Context) *model.User {
|
func GetCurrentUser(c *gin.Context) *model.User {
|
||||||
data, _ := c.Get(constants.ContextUser)
|
data, _ := c.Get(constants.ContextUser)
|
||||||
|
if data == nil {
|
||||||
|
return &model.User{}
|
||||||
|
}
|
||||||
return data.(*model.User)
|
return data.(*model.User)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user