Skip to content

Commit 95cbf2f

Browse files
authored
fix(AuthenticatorState): Making move(to:) public (#66)
1 parent f9ead67 commit 95cbf2f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Sources/Authenticator/Models/AuthenticatorState.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,19 @@ public class AuthenticatorState: ObservableObject, AuthenticatorStateProtocol {
4848
}
4949
}
5050

51-
func move(to initialStep: AuthenticatorInitialStep) {
51+
/// Manually moves the Authenticator to an initial step
52+
/// - Parameter initialStep: The desired ``AuthenticatorInitialStep``
53+
public func move(to initialStep: AuthenticatorInitialStep) {
5254
if case .signedIn(_) = step {
5355
log.error("Cannot move to \(initialStep), the user is currently signed in. Call signOut first.")
5456
return
5557
}
5658

59+
guard step != .init(from: initialStep) else {
60+
log.warn("Attempted to move to \(initialStep), but the Authenticator is already in that step.")
61+
return
62+
}
63+
5764
setCurrentStep(.init(from: initialStep))
5865
}
5966

Sources/Authenticator/Models/AuthenticatorStep.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public struct AuthenticatorInitialStep: Equatable {
2828
/// An `AuthenticatorStep` represents a "state" or "view" for the Authenticator component within its lifecycle.
2929
public struct AuthenticatorStep: Equatable {
3030
private let name: String
31-
//private(set) public var state: State = .signedOut
3231

3332
private init(_ name: String) {
3433
self.name = name

0 commit comments

Comments
 (0)