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

import NevisMobileAuthentication

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