show alert after deleting account

This commit is contained in:
Satindar Dhillon 2022-07-13 09:32:39 -07:00
parent e6e954c7ad
commit fbb2565d11
3 changed files with 14 additions and 2 deletions

View file

@ -40,7 +40,7 @@ import Views
do {
try await dataService.deleteAccount(userID: currentViewer.unwrappedUserID)
authenticator.logout(dataService: dataService)
authenticator.logout(dataService: dataService, showAppleRevokeTokenAlert: true)
} catch {
deleteAccountErrorMessage = "We were unable to delete your account."
}

View file

@ -8,6 +8,7 @@ struct WelcomeView: View {
@EnvironmentObject var dataService: DataService
@EnvironmentObject var authenticator: Authenticator
@Environment(\.horizontalSizeClass) var horizontalSizeClass
@Environment(\.openURL) var openURL
@StateObject private var viewModel = RegistrationViewModel()
@ -20,6 +21,9 @@ struct WelcomeView: View {
@State private var selectedEnvironment = AppEnvironment.initialAppEnvironment
@State private var containerSize: CGSize = .zero
// swiftlint:disable:next line_length
let deletedAccountConfirmationMessage = "Your account has been deleted. Additional steps may be needed if Sign in with Apple was used to register."
func handleHiddenGestureAction() {
if !Bundle.main.isAppStoreBuild {
showDebugModal = true
@ -205,6 +209,12 @@ struct WelcomeView: View {
.sheet(isPresented: $showDebugModal) {
DebugMenuView(selectedEnvironment: $selectedEnvironment)
}
.alert(deletedAccountConfirmationMessage, isPresented: $authenticator.showAppleRevokeTokenAlert) {
Button("View Details") {
openURL(URL(string: "https://support.apple.com/en-us/HT210426")!)
}
Button("Dismiss") { self.authenticator.showAppleRevokeTokenAlert = false }
}
}
}
.preferredColorScheme(.light)

View file

@ -18,6 +18,7 @@ public final class Authenticator: ObservableObject {
}
@Published public internal(set) var isLoggedIn: Bool
@Published public var showAppleRevokeTokenAlert = false
let networker: Networker
@ -36,11 +37,12 @@ public final class Authenticator: ObservableObject {
ValetKey.authToken.value()
}
public func logout(dataService: DataService) {
public func logout(dataService: DataService, showAppleRevokeTokenAlert _: Bool = false) {
dataService.resetCoreData()
clearCreds()
Authenticator.unregisterIntercomUser?()
isLoggedIn = false
showAppleRevokeTokenAlert = true
}
public func clearCreds() {