Skip to content

Commit

Permalink
Merge branch 'main' into dhruv-documentation-writing
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvna1k authored Mar 14, 2024
2 parents 2c1701c + cc23b5b commit 57b0435
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
20 changes: 19 additions & 1 deletion Prisma/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,25 @@ struct HomeView: View {
}
.verifyRequiredAccountDetails(Self.accountEnabled)
.task {
await standard.authorizeAccessGroupForCurrentUser()
guard let user = Auth.auth().currentUser else {
print("No signed in user.")
return
}
let accessGroup = "637867499T.edu.stanford.cs342.2024.behavior"

guard (try? Auth.auth().getStoredUser(forAccessGroup: accessGroup)) == nil else {
print("Access group already shared ...")
return
}

do {
try Auth.auth().useUserAccessGroup(accessGroup)
try await Auth.auth().updateCurrentUser(user)
} catch let error as NSError {
print("Error changing user access group: %@", error)
// log out the user if fails
try? Auth.auth().signOut()
}
}
}
}
Expand Down
23 changes: 22 additions & 1 deletion Prisma/Onboarding/AccountOnboarding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,35 @@ import SwiftUI

struct AccountOnboarding: View {
@Environment(Account.self) private var account

@Environment(PrismaStandard.self) private var standard
@Environment(OnboardingNavigationPath.self) private var onboardingNavigationPath


var body: some View {
AccountSetup { _ in
Task {
await standard.authorizeAccessGroupForCurrentUser()
guard let user = Auth.auth().currentUser else {
print("No signed in user.")
return
}
let accessGroup = "637867499T.edu.stanford.cs342.2024.behavior"

guard (try? Auth.auth().getStoredUser(forAccessGroup: accessGroup)) == nil else {
print("Access group already shared ...")
return
}

do {
try Auth.auth().useUserAccessGroup(accessGroup)
try await Auth.auth().updateCurrentUser(user)
} catch let error as NSError {
print("Error changing user access group: %@", error)
// log out the user if fails
try? Auth.auth().signOut()
}


// Placing the nextStep() call inside this task will ensure that the sheet dismiss animation is
// played till the end before we navigate to the next step.
await standard.setAccountTimestamp()
Expand Down

0 comments on commit 57b0435

Please sign in to comment.