{{!
    This file is part of Moodle - http://moodle.org/

    Moodle is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Moodle is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
    @template tool_mfa/verification_form

    Template to display the MFA verification form and options.

    Example context (json):
    {
    "logintitle": "We need to verify your identity",
    "logindesc": "Use the Google Authenticator app to generate a code.",
    "form": "<form id=\"mfa-verify-form\" method=\"POST\" action=\"https:\/\/webserver\/admin\/tool\/mfa\/auth.php\"></form>",
    "hasadditionalfactors": true,
    "additionalfactors": [
        {
        "name": "webauthn",
        "loginoption": "Use authenticator token"
        }
    ],
    "authurl": "https:\/\/webserver\/admin\/tool\/mfa\/auth.php",
    "supportlink": "<a href=\"https:\/\/webserver\/user\/contactsitesupport.php\">Contact your site support<\/a>",
    "disablefactor": false
    }
}}

<div class="tool-mfa-verify-container">
    <div class="d-flex align-items-start pb-2 {{#disablefactor}}text-muted{{/disablefactor}}">
        <div class="mb-2">
            <h1 class="h2 mb-2">{{logintitle}}</h1>
            <p class="text-muted">{{{logindesc}}}</p>
        </div>
    </div>
    <div class="mfa-verify-form">
        {{{form}}}
    </div>
    <div class="form-container text-center mt-3">
        <div class="d-flex justify-content-center">
            <form id="cancelmfa" method="POST" action="{{{authurl}}}">
                <input type="hidden" id="{{uniqid}}-logout" name="logout" value="true">
                <input type="hidden" name="sesskey" value="{{sesskey}}">
                <input type="submit" class="btn btn-link"
                    name="cancelmfa" id="cancelmfa_button"
                    value="{{#str}} backtologin, tool_mfa {{/str}}">
            </form>
        </div>
    </div>
    {{#hasadditionalfactors}}
    <div class="login-separator my-5">{{#str}}loginseparatoror{{/str}}</div>
    {{/hasadditionalfactors}}
    {{#additionalfactors}}
    <form class="pt-2" id="{{uniqid}}-nextfactor" method="POST" action="{{{authurl}}}">
        <input type="hidden" id="{{uniqid}}-factorname" name="factorname" value="{{name}}">
        <button class="btn btn-secondary w-100 mb-2 {{#disable}}disabled{{/disable}}" type="submit">
            <span>{{loginoption}}</span>
        </button>
    </form>
    {{/additionalfactors}}
    <div class="form-container text-center mt-3">
        {{#supportlink}}
        <div class="tool-mfa-site-support mt-4">
            {{#str}} needhelp, tool_mfa {{/str}} {{{supportlink}}}
        </div>
        {{/supportlink}}
    </div>
</div>

