<%doc>
############################################################################
###    (C)opyright 2003 - 2008 RIPE NCC
###    This file is part of DNSMon
###
###    DNSMon 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.
###
###    DNSMon 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 DNSMon.  If not, see <http://www.gnu.org/licenses/>.
############################################################################
</%doc>
<%args>
	$group => undef
	$user => undef
	$password => undef
	@message => ()
</%args>
<%init>
	my $suggestion;
	eval {
		use Crypt::RandPasswd;
		$suggestion = Crypt::RandPasswd::word( 6, 8);
	  };
	my $tabix = 10;
</%init>
<%perl>
if (%ARGS && not @message) {
	$m->comp( '/lib/authenticate:change_password',
		%ARGS
	  );
} else {
</%perl>

<table>
	<tr>
		<td>Logged in as:</td><td> <b><% $TICKET->logname() =~ /^\.(.*)$/ %></b> since <% strftime("%a %e %B %Y %T %Z",localtime($TICKET->lastAccessTime())) %></td>
	</tr>
	<tr>
		<td>Allowed views:</td><td> <% join(", ", sort $TICKET->subject->getPrincipals->[0]->getGroups()) %></td>
	</tr>
</table>

<div class="center">
<form action="<% $CONFIG{change_password_url} %>" method="post">

	<input type="hidden" name="conf" value="<% $CONFIG{conf} %>" /> 
	<input type="hidden" name="forward_success" value="<& /lib/url, host => $r->hostname, port => $r->get_server_port, path => '/dns-servmon/password_changed' &>" />
	<input type="hidden" name="forward_fail" value="<& /lib/url, host => $r->hostname, port => $r->get_server_port, path => '/dns-servmon/auth/password' &>" />

	<br />

	<table summary="Change password">
		<tr>
			<td>Current Password:</td>
			<td><input tabindex="<% $tabix++ %>" type="password" name="old_password" /></td>
		</tr>
% if ($suggestion) {
		<tr>
			<td>Suggestion:</td>
			<td><% $suggestion %></td>
		</tr>
% }

		<tr>
			<td>New Password:</td>
			<td><input tabindex="<% $tabix++ %>" type="password" name="new1_password" /></td>
		</tr>

		<tr>
			<td>Confirm New Password:</td>
			<td><input tabindex="<% $tabix++ %>" type="password" name="new2_password" /></td>
		</tr>

		<tr>
			<td colspan="2">
				<input tabindex="<% $tabix++ %>" type="submit" name="passwd" value="Change Password" />
			</td>
		</tr>
	</table>
</form>
</div>
%}
% if (@message) {
  <p class="message">Message:
      <ul>
%   foreach my $e (@message) {
        <li class="message"><% $e %></li>
%   }
      </ul>
  </p>
% }
