<?xml version="1.0"?>
<!--
/**
 * MageSpecialist
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to info@magespecialist.it so we can send you a copy immediately.
 *
 * @category   MSP
 * @package    MSP_ReCaptcha
 * @copyright  Copyright (c) 2017 Skeeller srl (http://www.magespecialist.it)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="MSP\ReCaptcha\Api\ValidateInterface" type="MSP\ReCaptcha\Model\Validate"/>

    <!-- Backend Login -->
    <virtualType name="MSP\ReCaptcha\Model\Provider\IsCheckRequired\Adminhtml\Login"
                 type="MSP\ReCaptcha\Model\IsCheckRequired">
        <arguments>
            <argument name="area" xsi:type="string">adminhtml</argument>
        </arguments>
    </virtualType>
    <virtualType name="MSP\ReCaptcha\Observer\Adminhtml\LoginObserver"
                 type="MSP\ReCaptcha\Observer\ReCaptchaObserver">
        <arguments>
            <argument name="isCheckRequired"
                      xsi:type="object">MSP\ReCaptcha\Model\Provider\IsCheckRequired\Adminhtml\Login</argument>
            <argument name="failureProvider"
                      xsi:type="object">MSP\ReCaptcha\Model\Provider\Failure\AuthenticationExceptionFailure</argument>
        </arguments>
    </virtualType>

    <!-- Backend Forgot password -->
    <virtualType name="MSP\ReCaptcha\Model\Provider\Failure\RedirectUrl\ForgotPassword"
                 type="MSP\ReCaptcha\Model\Provider\Failure\RedirectUrl\SimpleUrlProvider">
        <arguments>
            <argument name="urlPath" xsi:type="string">*/*/forgotpassword</argument>
        </arguments>
    </virtualType>
    <virtualType name="MSP\ReCaptcha\Model\Provider\Failure\ForgotPasswordObserver"
                 type="MSP\ReCaptcha\Model\Provider\Failure\ObserverRedirectFailure">
        <arguments>
            <argument name="redirectUrlProvider"
                      xsi:type="object">MSP\ReCaptcha\Model\Provider\Failure\RedirectUrl\ForgotPassword</argument>
        </arguments>
    </virtualType>
    <virtualType name="MSP\ReCaptcha\Model\Provider\IsCheckRequired\Adminhtml\ForgotPassword"
                 type="MSP\ReCaptcha\Model\IsCheckRequired">
        <arguments>
            <argument name="area" xsi:type="string">adminhtml</argument>
            <argument name="requireRequestParam" xsi:type="string">email</argument>
        </arguments>
    </virtualType>
    <virtualType name="MSP\ReCaptcha\Observer\Adminhtml\ForgotPasswordObserver"
                 type="MSP\ReCaptcha\Observer\ReCaptchaObserver">
        <arguments>
            <argument name="isCheckRequired"
                      xsi:type="object">MSP\ReCaptcha\Model\Provider\IsCheckRequired\Adminhtml\ForgotPassword</argument>
            <argument name="failureProvider"
                      xsi:type="object">MSP\ReCaptcha\Model\Provider\Failure\ForgotPasswordObserver</argument>
        </arguments>
    </virtualType>
</config>
