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

import NevisMobileAuthentication

struct PasswordsChangeMethodHandler: MethodHandler {
	func execute(using _: MobileAuthenticationClient, with message: ChannelInMessage) {
		let message: PasswordsChangeMessage = validate(message: message)
		let operation: PasswordChangeOperation = OperationCache.shared.read(by: message.operationId)
		let state: PasswordChangeState = validate(state: operation.state)
		state.change(password: message.oldPassword, newPassword: message.newPassword)
		MethodChannelHandler.shared.resolve(method: .passwordsChange)
	}
}
