func (us BoltUserStore) Update(user *model.User) StoreChannel { storeChannel := make(StoreChannel) go func() { result := StoreResult{} if len(user.Password) > 0 { if user.PasswordConfirmation != user.Password { result.Err = model.NewAppError("BoltUserStore.Update", "When update password must be equal to passwordConfirmation", "user_id"+user.Id) storeChannel <- result close(storeChannel) } } if us.isLoginTaken(user.Login) { result.Err = model.NewAppError("BoltUserStore.Save", "User Login already taken", "user_login="+user.Login) storeChannel <- result close(storeChannel) return } user.PreSave() userJson := user.ToJson() us.usersBucket.Put([]byte(user.Id), []byte(userJson)) us.usersByLoginBucket.Put([]byte(user.Login), []byte(user.Id)) result.Data = user storeChannel <- result return }() return storeChannel }
func (us BoltUserStore) Save(user *model.User) StoreChannel { storeChannel := make(StoreChannel) go func() { result := StoreResult{} if len(user.Id) > 0 { result.Err = model.NewAppError("BoltUserStore.Save", "Must call update for exisiting user", "user_id="+user.Id) storeChannel <- result close(storeChannel) return } if us.isLoginTaken(user.Login) { result.Err = model.NewAppError("BoltUserStore.Save", "User Login already taken", "user_login="******"BoltUserStore.Save", "User Login already taken", "PasswordConformition="+user.PasswordConfirmation+" Password="+user.Password) storeChannel <- result close(storeChannel) return } user.PreSave() userJSON := user.ToJson() us.usersBucket.Put([]byte(user.Id), []byte(userJSON)) us.usersByLoginBucket.Put([]byte(user.Login), []byte(user.Id)) result.Data = user storeChannel <- result close(storeChannel) }() return storeChannel }