func (a *ApplicationController) CreateApplicationHandler(c *gin.Context) { body := &ApplicationModel{} if err := c.Bind(body); err != nil { log.Error(RestError(c, err)) return } if body.Name == "" { log.Error(RestErrorInvalidBody(c)) return } email := ApiUser(c).Email app := models.JSON{ db.ID_FIELD: body.Id, db.NAME_FIELD: body.Name, db.OWNER_FIELD: email, db.MASTER_KEY_FIELD: strings.ToUpper(utils.GetCleanUUID()), } appId, err := a.DbService.CreateApp(email, app) if err != nil { log.Error(RestError(c, err)) return } RespondId(appId, c) }
func (d *dbService) setId(item models.JSON) string { if item[ID_FIELD] == nil || item[ID_FIELD] == "" { item[ID_FIELD] = utils.GetCleanUUID() } return item[ID_FIELD].(string) }
func init() { c = client.NewApiClientClean() email := utils.GetCleanUUID() password := utils.GetCleanUUID() err := c.Register(email, password) if err != nil { panic(err) return } token, err := c.Login(email, password) if err != nil { panic(err) return } c.Token = token appId, err := c.CreateApp(utils.GetCleanUUID()) if err != nil { panic(err) return } c.AppId = appId err = c.AppRegister(email, password) if err != nil { panic(err) return } appToken, err := c.AppLogin(email, password) if err != nil { panic(err) return } c.Token = appToken }