aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catdap.yml3
-rw-r--r--lib/CatDap/Controller/user.pm34
-rw-r--r--lib/CatDap/View/TT.pm2
-rw-r--r--root/index.tt11
-rw-r--r--root/register/complete.tt11
-rw-r--r--root/template/footer3
-rw-r--r--root/template/header16
-rw-r--r--root/template/html13
-rw-r--r--root/template/layout40
-rw-r--r--root/template/pre3
-rw-r--r--root/template/wrapper11
-rw-r--r--root/ttsite.css252
-rw-r--r--root/user/firstlogin.tt18
-rw-r--r--root/user/index.tt32
-rw-r--r--root/user/password.tt22
15 files changed, 447 insertions, 24 deletions
diff --git a/catdap.yml b/catdap.yml
index 3a62e3a..3e12daa 100644
--- a/catdap.yml
+++ b/catdap.yml
@@ -10,6 +10,9 @@
name: CatDap
default_view: TT
+organisation: Mageia
+apptitle: Mageia Identity Management
+
Model::Proxy:
base: ou=People,dc=mageia,dc=org
dn: cn=catdap,ou=System Accounts,dc=mageia,dc=org
diff --git a/lib/CatDap/Controller/user.pm b/lib/CatDap/Controller/user.pm
index 0603217..90dbb0e 100644
--- a/lib/CatDap/Controller/user.pm
+++ b/lib/CatDap/Controller/user.pm
@@ -53,8 +53,8 @@ sub auto : Private {
#TODO: ppolicy ....
$c->stash(errors => ['Incorrect username or password']);
$c->stash(template => 'index.tt');
- $c->forward('/index');
- $c->detach;
+ #$c->forward('/index');
+ $c->detach('/user/login');
} else {
#if (defined $c->user->pwdReset) {
# $c->res->redirect('/user');
@@ -65,6 +65,7 @@ sub auto : Private {
-cipher => 'Blowfish'
) or die $!;
$c->session->{enc_password} = $cipher->encrypt($c->req->param('password') || $c->req->param('key'));
+ $c->stash(pages => roles2pages($c->user->roles));
$c->session->{dn} = $c->user->ldap_entry->dn;
$c->session->{user} = $c->req->param('username');
$password = $c->req->param('password') || $c->req->param('key');
@@ -78,6 +79,8 @@ sub auto : Private {
$password = $cipher->decrypt($c->session->{enc_password});
$c->log->info("Re-authenticating user " . $c->session->{user});
$c->authenticate({username => $c->session->{user},password => $password});
+
+ $c->stash(pages => roles2pages($c->user->roles));
$c->log->info($@) if $@;
return 1;
}
@@ -186,6 +189,7 @@ sub index :Path :Args(0) {
may => \@may,
must => \@must,
});
+ $c->stash(subpages => gensubpages());
}
sub add : Local {
@@ -223,8 +227,10 @@ sub delete : Local : Args(2) {
sub password : Local {
my ( $self, $c) = @_;
my ($mesg,$newpass,$cipher);
+ $c->stash(subpages => gensubpages());
if ( not defined $c->req->param('password') or not defined $c->req->param('newpassword1') or not defined $c->req->param('newpassword2')) {
#if ( not defined $c->req->param('newpassword1') or not defined $c->req->param('newpassword2')) {
+
$c->detach;
}
if ($c->req->param('newpassword1') eq $c->req->param('newpassword2')) {
@@ -318,6 +324,30 @@ sub logout : Local {
$c->res->redirect('/');
}
+sub roles2pages : Private {
+ my @roles = @_;
+ my @pages;
+ foreach my $role (sort @roles) {
+ if ($role =~ /^(\w+) ?(\w*) (Admin)s$/) {
+ my $page = lc("/$3/$1$2");
+ push @pages,{ page => lc("/$3/$1$2"), title => "$1 $2 $3"};
+ }
+ }
+ return \@pages;
+}
+
+sub gensubpages : Private {
+ my ($type) = @_;
+ my @subpagenames;
+ @subpagenames = (
+ { page => './', title => "Edit"},
+ { page => 'password', title => "Change password"},
+ );
+ return \@subpagenames;
+}
+
+
+
=head1 AUTHOR
Buchan Milne
diff --git a/lib/CatDap/View/TT.pm b/lib/CatDap/View/TT.pm
index 0cd6acb..f63d775 100644
--- a/lib/CatDap/View/TT.pm
+++ b/lib/CatDap/View/TT.pm
@@ -8,6 +8,8 @@ use base 'Catalyst::View::TT';
__PACKAGE__->config(
TEMPLATE_EXTENSION => '.tt',
render_die => 1,
+ WRAPPER => 'template/wrapper',
+ PRE_PROCESS => 'template/pre',
);
=head1 NAME
diff --git a/root/index.tt b/root/index.tt
index 3b43806..73f890a 100644
--- a/root/index.tt
+++ b/root/index.tt
@@ -1,16 +1,5 @@
-[% MACRO l(text, args) BLOCK;
- c.localize(text, args);
-END; %]
-
-
<h2>[% l('Login') %]</h2>
-<span class="error">
-[% FOREACH error IN errors %]
-[% error %]<br/>
-[% END %]
-</span>
-
<form method=post action="/user">
<table border=0>
diff --git a/root/register/complete.tt b/root/register/complete.tt
index a4f07e2..0ffaa8c 100644
--- a/root/register/complete.tt
+++ b/root/register/complete.tt
@@ -1,16 +1,5 @@
-[% MACRO l(text, args) BLOCK;
- c.localize(text, args);
-END; %]
-
-
<h2>[% l('Registration completed') %]</h2>
-<span class="error">
-[% FOREACH error IN errors %]
-[% error %]<br/>
-[% END %]
-</span>
-
<p>
[% l('Registration was successful.') %]
[% l('Check your mail for activation instructions') %]
diff --git a/root/template/footer b/root/template/footer
new file mode 100644
index 0000000..78203d5
--- /dev/null
+++ b/root/template/footer
@@ -0,0 +1,3 @@
+<!-- BEGIN site/footer -->
+<!-- div id="copyright">&copy; [% c.config.organisation %] 2010</div -->
+<!-- END site/footer -->
diff --git a/root/template/header b/root/template/header
new file mode 100644
index 0000000..11ca573
--- /dev/null
+++ b/root/template/header
@@ -0,0 +1,16 @@
+<!-- BEGIN template/header -->
+<div class="masthead">
+<h1>[% c.config.apptitle %]</h1>
+</div>
+<div class="hnav">
+<!--div class="hnav" -->
+<ul class="hnav">
+[% FOREACH page IN pages %]
+<li><a href="[% c.uri_for(page.page) %]">[% page.title %]</a></li>
+[% END %]
+[% IF c.user.username %]
+<li>[ <a href="[% c.uri_for("/user") %]">[% c.user.username %]</a> ]<a href="/user/logout">Log out</a></li>
+[% END %]
+</ul>
+</div>
+<!-- END template/header -->
diff --git a/root/template/html b/root/template/html
new file mode 100644
index 0000000..c23fcfb
--- /dev/null
+++ b/root/template/html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <title>[% template.title or site.title %]</title>
+ <link rel="Stylesheet" href="/ttsite.css">
+ <!-- style type="text/css" -->
+ <!--% PROCESS ttsite.css %-->
+ <!-- /style -->
+ </head>
+ <body>
+[% content %]
+ </body>
+</html>
diff --git a/root/template/layout b/root/template/layout
new file mode 100644
index 0000000..8a6b601
--- /dev/null
+++ b/root/template/layout
@@ -0,0 +1,40 @@
+<!-- BEGIN template/header -->
+<div id="header">[% PROCESS template/header %]</div>
+<!-- END template/header -->
+
+<div id="outerColumnContainer">
+ <div id="leftColumn">
+ <div class="inside">
+ <div class="vnav">
+ <ul>
+ [% FOREACH subpage IN subpages %]
+ <li><a href="[% c.uri_for(subpage.page) %]">[% subpage.title %]</a></li>
+ [% END %]
+ </ul>
+ </div>
+ </div>
+ </div>
+
+ <div id="innerColumnContainer">
+ <!-- div id="SOWrap" -->
+ <div id="middleColumn">
+ <div class="inside">
+ [% IF errros %]
+ <span class="error">
+ [% FOREACH error IN errors %]
+ [% error %]<br/>
+ [% END %]
+ </span>
+ [% END %]
+ <div id="content">
+ [% content %]
+ </div>
+ </div>
+ <div class="clear"></div>
+ </div>
+ <div class="clear"></div>
+ </div>
+ <!-- /div -->
+ </div>
+</div>
+<!-- div id="footer">[% PROCESS template/footer %]</div -->
diff --git a/root/template/pre b/root/template/pre
new file mode 100644
index 0000000..581baf7
--- /dev/null
+++ b/root/template/pre
@@ -0,0 +1,3 @@
+[% MACRO l(text, args) BLOCK;
+ c.localize(text, args);
+END; %]
diff --git a/root/template/wrapper b/root/template/wrapper
new file mode 100644
index 0000000..8bfee46
--- /dev/null
+++ b/root/template/wrapper
@@ -0,0 +1,11 @@
+[% MACRO l(text, args) BLOCK;
+ c.localize(text, args);
+END; %]
+[% IF template.name.match('\.(css|js|txt)');
+ debug("Passing page through as text: $template.name");
+ content;
+ ELSE;
+ debug("Applying HTML page layout wrappers to $template.name\n");
+ content WRAPPER template/html + template/layout;
+ END;
+-%]
diff --git a/root/ttsite.css b/root/ttsite.css
new file mode 100644
index 0000000..520bb5b
--- /dev/null
+++ b/root/ttsite.css
@@ -0,0 +1,252 @@
+
+html {
+ height: 100%;
+ margin: 0;
+}
+
+body {
+ /*background-color: #ccc;*/
+ color: #000;
+ margin: 0;
+ padding: 0px;
+ height: 100%;
+}
+
+#header {
+ background-color: #eee;
+ border-bottom: 0px solid #fff;
+}
+
+#footer {
+ background-color: #ccc;
+ text-align: center;
+ /*border-top: 1px solid #000;*/
+ position: absolute;
+ /*top: 99%;*/
+ float: bottom;
+ left: 0px;
+ width: 100%;
+ height: 1em;
+ padding: 0px;
+ padding-bottom: 2px;
+ top: 100%;
+}
+
+#content {
+ padding: 10px;
+ vertical-align: top;
+}
+
+h1.title {
+ padding: 4px;
+ margin: 0px;
+}
+
+.message {
+ color: #000;
+}
+
+.error {
+ color: #f00;
+}
+
+
+/* Some stuff from skidoo_too.css */
+#outerColumnContainer
+{
+ /* reserves space for the left and right columns. you can use either
+ * padding, margins, or borders, depending on your needs. however you
+ * can use the border method to create a background color for both left
+ * and right columns
+ */
+ /*height: 98%;*/
+ border-left: solid 12em #eee;
+ border-right: solid 0em #eee;
+ /*border-bottom: solid 1em #fff;*/
+}
+#innerColumnContainer
+{
+ border: solid 0px #000;
+ border-width: 0 0px;
+ margin: 0 -1px; /* compensate for the borders because of
+ 100% width declaration */
+ width: 100%;
+ /*height: 90%;*/
+ /*z-index: 1;*/
+ background-color: #fff;
+ float: right;
+}
+#leftColumn, #middleColumn, #rightColumn, * html #SOWrap
+{
+ overflow: visible; /* fix for IE italics bug */
+ position: relative; /* fix some rendering issues */
+}
+#SOWrap
+{
+ float: left;
+ margin: 0 -1px 0 0;
+ width: 100%;
+ /*z-index: 3;*/
+}
+#middleColumn
+{
+ float: right;
+ margin: 0 0 0 -1px;
+ width: 100%;
+ /*z-index: 5;*/
+}
+#leftColumn
+{
+ float: left;
+ margin: 0 1px 0 -12em;
+ width: 12em;
+ /*z-index: 4;*/
+ height: 100%;
+ background-color: #eee;
+}
+#rightColumn
+{
+ float: right;
+ width: 14em;
+ margin: 0 -14em 0 1px;
+ /*z-index: 2;*/
+}
+
+/* vertical navigation stuff. mostly exactly as seen in the vnav.css styleheet
+ * in the original skidoo layout.
+ */
+.vnav
+{
+ margin: 0em 0;
+}
+.vnav ul, .vnav ul li
+{
+ margin: 0;
+ padding: 0;
+ list-style-type: none;
+ display: block;
+}
+.vnav ul
+{
+ border: solid 0px #fff;
+ border-bottom-width: 0;
+}
+.vnav ul li
+{
+ border-bottom: solid 0px #fff;
+}
+.vnav ul li, .vnav ul li a
+{
+ margin: 0;
+ display: block;
+ padding: 0;
+ line-height: normal;
+}
+.vnav ul li a
+{
+ display: block;
+ padding: 2px 5px 3px 5px;
+}
+.vnav ul li a, .vnav ul li a:link, .vnav ul li a:visited, .vnav ul li a:active, .vnav ul li a:hover
+{
+ text-decoration: none;
+ cursor: pointer;
+ background-color: #eee;
+ color: #000;
+}
+
+.vnav ul li a:hover
+{
+ text-decoration: none;
+ background-color: #ccc;
+}
+
+
+.vnav h3
+{
+ margin-bottom: 0;
+ padding-bottom: 0;
+ font-size: 126%;
+}
+* html .vnav ul li a/* hide from IE5.0/Win & IE5/Mac */
+{
+ height: 0.01%;
+}
+* html .vnav ul
+{
+ position: relative; /* IE needs this to fix a rendering problem */
+}
+
+/* horizontal navigation elements. create a DIV element with the class hnav
+ * and stick one unordered list inside it to generate a horizontal menu.
+ */
+.hnav
+{
+ border-bottom: solid 0px #fff;
+ text-align: center;
+}
+.hnav, .hnav ul li a
+{
+ /* need to middor veritcal padding on .hnav and child anchor elements
+ * because the anchors are _not_ block elements. since they are not
+ * block elements web browsers will not expand .hnav to contain them
+ * even with the extra padding. by applying the same padding to both
+ * the parent .hnav _looks_ like its containing the child anchor
+ * elements.
+ */
+ padding-top: 3px;
+ padding-bottom: 4px;
+}
+.hnav ul, .hnav ul li
+{
+ display: inline;
+ list-style-type: none;
+ margin: 0;
+ padding: 0;
+}
+.hnav ul li a
+{
+ margin: 0 -1px 0 0;
+ padding-left: 10px;
+ padding-right: 10px; /* short-hand padding attribute would overwrite
+ top/bottom padding set in a previous rule */
+ border-left: solid 0px #000;
+ border-right: solid 0px #000;
+ white-space: nowrap;
+}
+.hnav ul li a:link, .hnav ul li a:visited, .hnav ul li a:active, .hnav ul li a:hover
+{
+ text-decoration: none;
+ color: #7f899a;
+}
+.hnav ul li a:hover
+{
+ text-decoration: none;
+ background-color: #ccc;
+}
+.hnav ul li span.divider
+{
+ display: none;
+}
+* html .hnav ul li, * html .hnav ul li a
+{
+ width: 1%; /* IE/Mac needs this */
+ display: inline-block; /* IE/Mac needs this */
+ /* \*/
+ width: auto;
+ display: inline;
+ /* reset above hack */
+}
+* html .hnav, * html .hnav ul a
+{
+ /* \*/ height: 0.01%; /* hasLayout hack to fix render bugs in IE/Win.
+ IE/Mac will ignore this rule. */
+}
+* html .HNAV
+{
+ padding: 0; /* IE5/Win will resize #hnav to fit the heights of its
+ inline children that have vertical padding. So this
+ incorrect case selector hack will be applied only by
+ IE 5.x/Win */
+}
+
diff --git a/root/user/firstlogin.tt b/root/user/firstlogin.tt
new file mode 100644
index 0000000..33d0e60
--- /dev/null
+++ b/root/user/firstlogin.tt
@@ -0,0 +1,18 @@
+<html>
+<form method=post>
+<table border='0'>
+<tr>
+<td>New Password</td>
+<td><input name='newpassword1' type='password'></td>
+</tr>
+<tr>
+<td>Repeat New Password</td>
+<td><input name='newpassword2' type='password'></td>
+</tr>
+<tr>
+<td></td>
+<td align=right><input type='submit' value='Change'></td>
+</tr>
+</table>
+</form>
+</html>
diff --git a/root/user/index.tt b/root/user/index.tt
new file mode 100644
index 0000000..3147cd9
--- /dev/null
+++ b/root/user/index.tt
@@ -0,0 +1,32 @@
+<form method=post>
+<table border=0>
+<tr><th>Attribute</th><th>Value</th></tr>
+[% FOREACH attr IN values %]
+ <tr>
+ <td>[% attr.name %]</td>
+ <td>[% FOREACH val IN attr.values %][% IF attr.editable %]<input type=hidden name="[% attr.name %]_old" value="[% val %]"><input name="[% attr.name %]_new" value="[% val %]">[% ELSE %][% val %]<br/>[% END %]
+[% IF attr.addable AND attr.editable %]<a href="/user/add/[% attr.name %]">Add</a>[% END %]
+[% IF attr.removable AND attr.editable %]<a href="/user/delete/[% attr.name %]/[% val %]">Delete</a>[% END %]
+ [% END %]</td>
+ </tr>
+[% END %]
+<tr><td colspan=2 align=center><input type='Submit' value='Update'></td></tr>
+</table>
+</form>
+
+<form method=post action=/user/add>
+<table>
+<tr>
+<td>
+ <select name='attribute'>[% FOREACH attr IN may %]
+ <option value="[% attr %]">[% attr %]</option>[% END %]
+ </select>
+</td>
+<td><input name='value'>
+</td>
+<td>
+ <input type=submit value='Add'>
+</td>
+</tr>
+</table>
+</form>
diff --git a/root/user/password.tt b/root/user/password.tt
new file mode 100644
index 0000000..ade4e11
--- /dev/null
+++ b/root/user/password.tt
@@ -0,0 +1,22 @@
+<html>
+<form method=post>
+<table border='0'>
+<tr>
+<td>Current password</td>
+<td><input name='password' type='password'></td>
+</tr>
+<tr>
+<td>New Password</td>
+<td><input name='newpassword1' type='password'></td>
+</tr>
+<tr>
+<td>Repeat New Password</td>
+<td><input name='newpassword2' type='password'></td>
+</tr>
+<tr>
+<td></td>
+<td align=right><input type='submit' value='Change'></td>
+</tr>
+</table>
+</form>
+</html>