Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(auth): update swift passwordless autosignin Combine snippets #8132

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -822,24 +822,29 @@ func confirmSignUp(for username: String, with confirmationCode: String) -> AnyCa
}
}
receiveValue: { confirmSignUpResult in
if case .completeAutoSignIn = confirmSignUpResult.nextStep {
let _ = Amplify.Publisher.create {
try await Amplify.Auth.autoSignIn()
}.sink {
if case let .failure(authError) = $0 {
print("Auto Sign in failed \(authError)")
}
}
receiveValue: { autoSignInResult in
if autoSignInResult.isSignedIn {
print("Auto Sign in succeeded")
}
}
if case let .completeAutoSignIn(session) = confirmSignUpResult.nextStep {
print("Confirm Sign Up succeeded. Next step is auto sign in")
// call `autoSignIn()` API to complete sign in
} else {
print("Confirm sign up result completed: \(confirmSignUpResult.isSignUpComplete)")
}
}
}

func autoSignIn() -> AnyCancellable {
Amplify.Publisher.create {
try await Amplify.Auth.autoSignIn()
}.sink {
if case let .failure(authError) = $0 {
print("Auto Sign in failed \(authError)")
}
}
receiveValue: { autoSignInResult in
if autoSignInResult.isSignedIn {
print("Auto Sign in succeeded")
}
}
}
```

</Block>
Expand Down