From 3ff1fb4e10fdaef86527c10bd416e988d2a62a49 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Fri, 5 Apr 2013 01:03:44 -0700 Subject: login/login pages and cookie/session-based auth --- httemplate/autohandler | 2 +- httemplate/elements/header.html | 33 ++++++++------------ httemplate/elements/logout.html | 44 -------------------------- httemplate/loginout/login.html | 68 +++++++++++++++++++++++++++++++++++++++++ httemplate/loginout/logout.html | 28 ++++++----------- 5 files changed, 92 insertions(+), 83 deletions(-) delete mode 100644 httemplate/elements/logout.html create mode 100644 httemplate/loginout/login.html (limited to 'httemplate') diff --git a/httemplate/autohandler b/httemplate/autohandler index c326e3e18..b5b1071c1 100644 --- a/httemplate/autohandler +++ b/httemplate/autohandler @@ -46,5 +46,5 @@ if ( UNIVERSAL::can(dbh, 'sprintProfile') ) { <%cleanup> - dbh->commit(); + dbh->commit() if dbh; diff --git a/httemplate/elements/header.html b/httemplate/elements/header.html index c6ad3c387..4f5015e7a 100644 --- a/httemplate/elements/header.html +++ b/httemplate/elements/header.html @@ -2,18 +2,18 @@ Example: - include( '/elements/header.html', - { - 'title' => 'Title', - 'menubar' => \@menubar, - 'etc' => '', #included in tag, for things like onLoad= - 'head' => '', #included before closing tag - 'nobr' => 0, #1 for no

after the title - } - ); - - #old-style - include( '/elements/header.html', 'Title', $menubar, $etc, $head); + <& /elements/header.html', + { + 'title' => 'Title', + 'menubar' => \@menubar, + 'etc' => '', #included in tag, for things like onLoad= + 'head' => '', #included before closing tag + 'nobr' => 0, #1 for no

after the title + } + &> + + %#old-style + <& /elements/header.html, 'Title', $menubar, $etc, $head &> @@ -41,13 +41,6 @@ Example: <% include('init_overlib.html') |n %> <% include('rs_init_object.html') |n %> - <% include('logout.html') |n %> -% my $timeout = $conf->config('logout-timeout'); -% if ( $timeout && $timeout =~ /^\s*\d+\s*$/ ) { - -% } <% $head |n %> @@ -59,7 +52,7 @@ Example: <% $company_name || 'ExampleCo' %> - Logged in as <% getotaker %>  logout
Preferences + Logged in as <% getotaker %>  logout
Preferences % if ( $conf->config("ticket_system") % && FS::TicketSystem->access_right(\%session, 'ModifySelf') ) { | Ticketing preferences diff --git a/httemplate/elements/logout.html b/httemplate/elements/logout.html deleted file mode 100644 index 313dbfaf1..000000000 --- a/httemplate/elements/logout.html +++ /dev/null @@ -1,44 +0,0 @@ -<%doc> - -Example: - - include( '/elements/logout.html'); - This is the logout link. - - - diff --git a/httemplate/loginout/login.html b/httemplate/loginout/login.html new file mode 100644 index 000000000..e5b45893b --- /dev/null +++ b/httemplate/loginout/login.html @@ -0,0 +1,68 @@ +<& /elements/header-minimal.html, 'Login' &> + + +
+ +
+ Login +

+ +% if ( $error ) { + <% $error |h %> +

+% } + +%#
+ + + + + + + + + + + + +
Username:
Password:
+
+ + + +
+ +
+ + +<%init> + +my %error = ( + 'no_cookie' => '', #First login, don't display an error + 'bad_cookie' => 'Bad Cookie', #timed out? server reboot? + 'bad_credentials' => 'Incorrect username / password', + 'logout' => 'You have been logged out.', +); + +my $url_string = CGI->new->url; + +my $error = $cgi->param('logout') || $r->prev->subprocess_env("AuthCookieReason"); +$error = exists($error{$error}) ? $error{$error} : $error; + +#fake a freeside path for /login so we get our .css. shrug +$url_string =~ s/login$/freeside\/login/ unless $url_string =~ /freeside\//; + +#even though this is kludgy and false laziness w/CGI.pm + $url_string =~ s{ / index\.html /? $ } + {/}x; + $url_string =~ + s{ + /(login|loginout) + ([\w\-\.\/]*) + $ + } + {}ix; + + $url_string .= '/' unless $url_string =~ /\/$/; + + diff --git a/httemplate/loginout/logout.html b/httemplate/loginout/logout.html index d8e1c634a..33b87feb0 100644 --- a/httemplate/loginout/logout.html +++ b/httemplate/loginout/logout.html @@ -1,18 +1,10 @@ - - - - - Logout page - - - -

-
- You have logged out. -
-

-
- You can log in again. -
- - +<% $cgi->redirect($fsurl.'?logout=logout') %> +<%init> + +my $auth_type = $r->auth_type; + +# Delete the cookie, etc. +$auth_type->logout($r); +#XXX etc: should delete the server-side session + + -- cgit v1.2.1