//
// Copyright © 2024 Nevis Security AG. All rights reserved.
//

import NevisMobileAuthentication

struct PasswordValidatedForPasswordChangeMethodHandler: MethodHandler {
	func execute(using _: MobileAuthenticationClient, with message: ChannelInMessage) {
		let message: PasswordValidatedMessage = validate(message: message)
		let operation: PasswordChangeOperation = OperationCache.shared.read(by: message.operationId)
		let state: PasswordValidateForPasswordChangeState = validate(state: operation.state)
		state.validatePassword(errorMessage: message.errorMessage, cause: message.cause)
		MethodChannelHandler.shared.resolve(method: .passwordValidatedForPasswordChange)
	}
}
