Skip to content

Commit

Permalink
Avoid Setting Data When No Data is Provided (#40)
Browse files Browse the repository at this point in the history
# Avoid Setting Data when no Data is Provided

## ♻️ Current situation & Problem
- SpeziFirebase tries to write a document when no data should be created
which can clash with possible security rules not allowing deletion.
- No document should be created on updating elements.

## ⚙️ Release Notes 
- Avoid Setting Data When No Data is Provided


## 📝 Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md).
  • Loading branch information
PSchmiedmayer authored Jul 26, 2024
1 parent 67981d0 commit e381b7d
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ public actor FirestoreAccountStorage: Module, AccountStorageConstraint {
do {
switch result {
case let .success(data):
guard !data.isEmpty else {
return
}

try await userDocument(for: identifier.accountId)
.setData(data, merge: true)
case let .failure(error):
Expand Down Expand Up @@ -137,7 +141,7 @@ public actor FirestoreAccountStorage: Module, AccountStorageConstraint {
switch result {
case let .success(data):
try await userDocument(for: identifier.accountId)
.setData(data, merge: true)
.updateData(data)
case let .failure(error):
throw error
}
Expand Down

0 comments on commit e381b7d

Please sign in to comment.