Skip to content

Commit

Permalink
fix(AuthenticatorState): Making move(to:) public
Browse files Browse the repository at this point in the history
  • Loading branch information
sebaland committed Apr 22, 2024
1 parent 71fb556 commit 2a28367
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 8 additions & 1 deletion Sources/Authenticator/Models/AuthenticatorState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,19 @@ public class AuthenticatorState: ObservableObject, AuthenticatorStateProtocol {
}
}

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

guard step != .init(from: initialStep) else {
log.warn("Attempted to move to \(initialStep), but the Authenticator is already in that step.")
return
}

setCurrentStep(.init(from: initialStep))
}

Expand Down
1 change: 0 additions & 1 deletion Sources/Authenticator/Models/AuthenticatorStep.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public struct AuthenticatorInitialStep: Equatable {
/// An `AuthenticatorStep` represents a "state" or "view" for the Authenticator component within its lifecycle.
public struct AuthenticatorStep: Equatable {
private let name: String
//private(set) public var state: State = .signedOut

private init(_ name: String) {
self.name = name
Expand Down

0 comments on commit 2a28367

Please sign in to comment.