1<?php
2// must be run within Dokuwiki
3if (!defined('DOKU_INC')) die();
4/**
5 * Google Authenticator Two Factor Form Action Plugin
6 *
7 * @author Daniel Popp dan@danpopp.net
8 */
9class action_plugin_authgoogle2fa extends DokuWiki_Action_Plugin {
10    /**
11     * Registers the event handlers.
12     */
13    function register(&$controller)
14    {
15        $enable = $this->getConf("use2fa_verify");
16        if($enable===1) {
17            $controller->register_hook('HTML_LOGINFORM_OUTPUT', 'BEFORE', $this, 'two_fa_login_form', array());
18        }
19    }
20    /**
21     * Handles the login form rendering.
22     */
23    function two_fa_login_form(&$event, $param) {
24        $twofa_form = "<label class=\"block\"><span>".$this->getLang('google_2fa')." </span><input type='password' name='t' class='edit'/></label><br/>";
25        $empty="";
26        $pos = $event->data->findElementByAttribute('type', 'submit');
27        $event->data->replaceElement($pos-1, $twofa_form);
28    }
29}
30?>
31