<%args> $userName => "" $password => "" <%once> use HTML::Entities; # For encode_entities() use Masterkey::Admin; <%perl> my $admin = new Masterkey::Admin(undef); my $tab = $admin->siteConf("redirectToTab"); if (defined $tab) { # For installations that default to a favoured tab. $m->comp("/mc/redirect.html", url => "$tab/"); } elsif ($userName eq "" || $password eq "") { # For sites requiring an initial login $m->comp("form", admin => $admin, userName => $userName, password => $password); } else { for (my $i = 1;; $i++) { my $ws = $admin->siteConf("login.$i.authRealm") or last; my $torus = new Masterkey::Admin::Torus($admin, $ws); my $rs = $torus->records(undef, { userName => $userName, password => $password }); my $users = $rs->records(); if (@$users) { my $tab = $admin->siteConf("login.$i.authRedirect"); return $m->comp("postLogin", tab => $tab, userName => $userName, password => $password, dest => "/"); } } $m->comp("form", admin => $admin, userName => $userName, password => $password, error => "No match"); } <%def form> <%args> $admin $userName $password $error => "" <%perl> my $title = $admin->siteConf("frontPageTitle"); my $h1 = $admin->siteConf("frontPageH1") || $title; my $logo = $admin->siteConf("logo"); my $icon = $admin->siteConf("siteIcon"); <% encode_entities($title) %> % if (defined $icon) { % }

<% $h1 %>

% if (defined $logo) {
% }
% if (defined $error) {

<% encode_entities($error) %>

% }

UserName:
Password:

Masterkey::Admin version <% $Masterkey::Admin::VERSION %>
Running on <% `hostname` %> (<% `cat /etc/issue | sed 's/[ ]*\\\\.//g' | tr -d '\012'` %>)

<%def postLogin> <%args> $tab $userName $password %# backwards-compatibility hack for old configurations % $tab = "/$tab" if $tab =~ /^console\//;