<%args>
  $msg             => undef
</%args>

    <& '/authentication/open_form.mhtml', 'session_id' => $session_id &>
    <h1><% i18nGettext ($name) %></h1>
    <p>
      <% i18nGettext ($desc) %>
    </p>
    <table>
      <tr>
        <td><% i18nGettext ('I18N_OPENXPKI_CLIENT_HTML_MASON_LOGIN') %></td>
        <td><& /lib/html/input.mhtml, 'type' => 'text', 'name' => 'login' &></td>
      </tr>
      <tr>
        <td><% i18nGettext ('I18N_OPENXPKI_CLIENT_HTML_MASON_PASSWD') %></td>
        <td><& /lib/html/input.mhtml, 'type' => 'password', 'name' => 'passwd' &></td>
      </tr>
    </table>
    <& '/authentication/close_form.mhtml' &>

<%init>
    my $session_id = $context->{session_id};
    my $client     = $context->{client};

    ## check that we must handle this message
    return $msg if ($msg->{SERVICE_MSG} ne "GET_PASSWD_LOGIN");

    ## was the login specified by the user?
    my %data = $m->request_args();
    #print STDERR "let's look for the login ...\n";
    if (exists $data{'login'})
    {
        #print  STDERR "DATA: ".$data{'login'}."\n";
        $msg = $client->send_receive_service_msg (
                            'GET_PASSWD_LOGIN',
                            {
                             'LOGIN'  => $data{'login'},
                             'PASSWD' => $data{'passwd'},
                            });
        #print  STDERR "second: ".$data{'login'}."\n";
        if ($msg->{'SERVICE_MSG'} ne 'GET_PASSWD_LOGIN')
        {
            return $msg;
        }
        #print  STDERR "third: ".$data{'login'}."\n";
    }
    #print STDERR "login passed\n";

    ## ok let's ask the user for the login and password
    ## cache the last message in the context
    my $name = $msg->{PARAMS}->{NAME};
    my $desc = $msg->{PARAMS}->{DESCRIPTION};
    $context->{msg} = $msg;
    $m->comp ('/lib/debug.mhtml',
              'level' => 99,
              'msg'   => "CONTEXT->MSG: ".Dumper($context->{msg}));
</%init>
<%once>
    use Data::Dumper;
</%once>
