Skip to content

Commit

Permalink
Helpers for invitation codes
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewTurk247 committed Mar 10, 2024
1 parent 2e271bb commit 3226bad
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions PAWS/PAWSStandard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ actor PAWSStandard: Standard, EnvironmentAccessible, HealthKitConstraint, Onboar
return Storage.storage().reference().child("users/\(details.accountId)")
}
}

private var invitationBucketReference: StorageReference {
get async throws {
Storage.storage().reference().child("invitations")
}
}


init() {
Expand Down Expand Up @@ -182,6 +188,20 @@ actor PAWSStandard: Standard, EnvironmentAccessible, HealthKitConstraint, Onboar
.collection("HealthKit") // Add all HealthKit sources in a /HealthKit collection.
.document(uuid.uuidString) // Set the document identifier to the UUID of the document.
}

private func invitationCodeIsValid(_ invitationCode: String) async -> Bool {
guard let validInvitationCodes = try? await invitationBucketReference.listAll() else {
return false
}

for item in validInvitationCodes.items {
if (try? await item.data(maxSize: 128).base64EncodedString()) == invitationCode {

Check failure on line 198 in PAWS/PAWSStandard.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint

Prefer For-Where Violation: `where` clauses are preferred over a single `if` inside a `for` (for_where)
return true
}
}

return false
}

func deletedAccount() async throws {
// delete all user associated data
Expand Down

0 comments on commit 3226bad

Please sign in to comment.