func (this *UserWebAPIV1Controller) Signup() { user := new(models.User) org := new(models.Organization) if err := json.Unmarshal(this.Ctx.Input.CopyBody(), &user); err != nil { this.JSONOut(http.StatusBadRequest, err.Error(), nil) return } else { if exist, _, err := org.Has(user.Username); err != nil { this.JSONOut(http.StatusBadRequest, err.Error(), nil) return } else if exist == true { this.JSONOut(http.StatusBadRequest, "Namespace is occupation already by organization.", nil) return } if exist, _, err := user.Has(user.Username); err != nil { this.JSONOut(http.StatusBadRequest, err.Error(), nil) return } else if exist == true { this.JSONOut(http.StatusBadRequest, "User already exist.", nil) return } else { user.Id = string(utils.GeneralKey(user.Username)) user.Created = time.Now().UnixNano() / int64(time.Millisecond) user.Gravatar = "/static/images/default-user-icon-profile.png" if err := user.Save(); err != nil { this.JSONOut(http.StatusBadRequest, err.Error(), nil) return } memo, _ := json.Marshal(this.Ctx.Input.Header) user.Log(models.ACTION_SIGNUP, models.LEVELINFORMATIONAL, models.TYPE_WEBV1, user.Id, memo) this.JSONOut(http.StatusOK, "User singup successfully!", nil) return } } }