Remove unnecessary code

This commit is contained in:
Jannis Mattheis 2018-02-28 19:46:53 +01:00 committed by Jannis Mattheis
parent d6b351f860
commit cb8fb2dfc2
1 changed files with 5 additions and 9 deletions

View File

@ -47,16 +47,12 @@ func (a *UserAPI) GetCurrentUser(ctx *gin.Context) {
func (a *UserAPI) CreateUser(ctx *gin.Context) { func (a *UserAPI) CreateUser(ctx *gin.Context) {
user := model.UserExternalWithPass{} user := model.UserExternalWithPass{}
if err := ctx.Bind(&user); err == nil { if err := ctx.Bind(&user); err == nil {
if len(user.Pass) == 0 { internal := a.toInternal(&user, []byte{})
ctx.AbortWithError(400, errors.New("password may not be empty")) if a.DB.GetUserByName(internal.Name) == nil {
a.DB.CreateUser(internal)
ctx.JSON(200, toExternal(internal))
} else { } else {
internal := a.toInternal(&user, []byte{}) ctx.AbortWithError(400, errors.New("username already exists"))
if a.DB.GetUserByName(internal.Name) == nil {
a.DB.CreateUser(internal)
ctx.JSON(200, toExternal(internal))
} else {
ctx.AbortWithError(400, errors.New("username already exists"))
}
} }
} }
} }