generated from StanfordBDHG/SwiftPackageTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Infrastructure changes to allow for seamless Single-Sign-On implement…
…ations. (#28) # Infrastructure changes to allow for seamless Single-Sign-On implementations. ## ♻️ Current situation & Problem While `IdentityProvider` are currently supported by `SpeziAccount`, there are some issues when trying to accommodate more extended use cases or certain limitations when combining different functionality. Below is a list of certain pain points including general improvements this PR makes: * Currently, account values requirements are globally applied. E.g., a configured password key is required for **all** account services. This doesn't fit very well for SSO providers as they intentionally don't collect passwords. Instead one would need a way of declaring AccountKeys required in the context of a given account services. This is resolved by changing the effect of the `RequiredAccountKeys` configuration an account service would provide and consequentially removing the need for the user to declare the `password` account value globally required. * We added a new `FollowUpInfoSheet` that automatically pops up after account setup to assist the user to provide any additional account details that are configured to be required. That is especially useful when using Identity Provider like Sign in with Apple that only provide a fixed set of user information. A new `verifyRequiredAccountDetails(_:)` modifier was added to implement the same logic on the global application level. This can be used that existing users always are in line with the latest configuration of your app. * The `accountRequired(_:setupSheet:)` modifier was added to enforce a user account at all times. * Added a new globally unique and stable `AccountId`, mandatory for each user account. * Fixed an issue where the SignupForm cancel confirmation would always pop up when using AccountKeys with default values. * Other fixes and improvements. ## ⚙️ Release Notes Added several infrastructure enhancements that allow for an improved user experience and compatibility when using identity providers. ### Breaking Changes * We introduce a new `accountId` (see `AccountIdKey`) account value that is mandatory for all user accounts. This is now also used as a primary identifier for `AccountStorageStandard`s. ## 📚 Documentation Documentation was updated respectively. ## ✅ Testing Test cases were added for new functionality or fixed functionality. ## 📝 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). --------- Co-authored-by: Paul Schmiedmayer <[email protected]>
- Loading branch information
1 parent
1eca293
commit 2f88e04
Showing
60 changed files
with
1,260 additions
and
340 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ import SpeziViews | |
import SwiftUI | ||
|
||
|
||
/// A summary view for ``SpeziAccountOverview`` that can be used as a Button to link to ``SpeziAccountOverview``. | ||
/// A account summary view that can be used to link to the ``AccountOverview``. | ||
/// | ||
/// Below is a short code example on how to use the `AccountHeader` view. | ||
/// | ||
|
@@ -37,7 +37,8 @@ public struct AccountHeader: View { | |
public enum Defaults { | ||
/// Default caption. | ||
@_documentation(visibility: internal) | ||
public static let caption = LocalizedStringResource("ACCOUNT_HEADER_CAPTION", bundle: .atURL(from: .module)) // swiftlint:disable:this attributes | ||
public static let caption = LocalizedStringResource("ACCOUNT_HEADER_CAPTION", bundle: .atURL(from: .module)) | ||
// swiftlint:disable:previous attributes | ||
} | ||
|
||
@EnvironmentObject private var account: Account | ||
|
@@ -47,12 +48,23 @@ public struct AccountHeader: View { | |
let accountDetails = account.details | ||
|
||
HStack { | ||
UserProfileView(name: accountDetails?.name ?? PersonNameComponents(givenName: "Placeholder", familyName: "Placeholder")) | ||
.frame(height: 60) | ||
.redacted(reason: account.details == nil ? .placeholder : []) | ||
.accessibilityHidden(true) | ||
if let accountDetails, | ||
let name = accountDetails.name { | ||
UserProfileView(name: name) | ||
.frame(height: 60) | ||
.accessibilityHidden(true) | ||
} else { | ||
Image(systemName: "person.crop.circle.fill") | ||
.resizable() | ||
.frame(width: 60, height: 60) | ||
.foregroundColor(Color(.systemGray3)) | ||
.accessibilityHidden(true) | ||
} | ||
|
||
VStack(alignment: .leading) { | ||
Text(accountDetails?.name?.formatted() ?? "Placeholder") | ||
let nameTitle = accountDetails?.name?.formatted(.name(style: .long)) ?? accountDetails?.userId ?? "Placeholder" | ||
|
||
Text(nameTitle) | ||
.font(.title2) | ||
.fontWeight(.semibold) | ||
.redacted(reason: account.details == nil ? .placeholder : []) | ||
|
@@ -89,7 +101,7 @@ public struct AccountHeader: View { | |
let details = AccountDetails.Builder() | ||
.set(\.userId, value: "[email protected]") | ||
.set(\.name, value: PersonNameComponents(givenName: "Andreas", familyName: "Bauer")) | ||
|
||
return NavigationStack { | ||
Form { | ||
Section { | ||
|
@@ -103,4 +115,37 @@ public struct AccountHeader: View { | |
} | ||
.environmentObject(Account(building: details, active: MockUserIdPasswordAccountService())) | ||
} | ||
|
||
#Preview { | ||
let details = AccountDetails.Builder() | ||
.set(\.userId, value: "[email protected]") | ||
|
||
return NavigationStack { | ||
Form { | ||
Section { | ||
NavigationLink { | ||
AccountOverview() | ||
} label: { | ||
AccountHeader() | ||
} | ||
} | ||
} | ||
} | ||
.environmentObject(Account(building: details, active: MockUserIdPasswordAccountService())) | ||
} | ||
|
||
#Preview { | ||
NavigationStack { | ||
Form { | ||
Section { | ||
NavigationLink { | ||
AccountOverview() | ||
} label: { | ||
AccountHeader() | ||
} | ||
} | ||
} | ||
} | ||
.environmentObject(Account(MockUserIdPasswordAccountService())) | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.