diff options
author | Yorhel <git@yorhel.nl> | 2008-10-31 19:03:32 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2008-10-31 19:03:32 +0100 |
commit | a586831218266c7e97191fac80291fe22e6d75d2 (patch) | |
tree | 119ff5a1314a3fc911722f0e279a4d5589610935 | |
parent | a1ed5e746d7bc6e6c2b2ba82f8fc17e3185afdef (diff) |
Logging in works now
...though the form and error handling is still missing
-rw-r--r-- | lib/VNDB/Handler/Users.pm | 27 | ||||
-rw-r--r-- | lib/VNDB/Util/CommonHTML.pm | 2 | ||||
m--------- | yawf | 0 |
3 files changed, 28 insertions, 1 deletions
diff --git a/lib/VNDB/Handler/Users.pm b/lib/VNDB/Handler/Users.pm index 441179ee..b9a95ab5 100644 --- a/lib/VNDB/Handler/Users.pm +++ b/lib/VNDB/Handler/Users.pm @@ -8,6 +8,7 @@ use YAWF ':html'; YAWF::register( qr{u([1-9]\d*)} => \&userpage, + qr{u/login} => \&login, qr{u/logout} => \&logout, ); @@ -27,6 +28,32 @@ sub userpage { } +sub login { + my $self = shift; + + return $self->resRedirect('/') if $self->authInfo->{id}; + + my $frm; + if($self->reqMethod eq 'POST') { + $frm = $self->formValidate( + { name => 'usrname', required => 1, minlength => 2, maxlength => 15, template => 'pname' }, + { name => 'usrpass', required => 1, minlength => 4, maxlength => 15, template => 'asciiprint' }, + ); + + (my $ref = $self->reqHeader('Referer')||'/') =~ s/^\Q$self->{url}//; + return if !$frm->{_err} && $self->authLogin($frm->{usrname}, $frm->{usrpass}, $ref); + $frm->{_err} = [ 'login_failed' ]; + } + + $self->htmlHeader(title => 'Login'); + div class => 'mainbox'; + h1 'Login'; + # login form and error messages here + end; + $self->htmlFooter; +} + + sub logout { shift->authLogout; } diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm index 2d41646e..ed1b6bca 100644 --- a/lib/VNDB/Util/CommonHTML.pm +++ b/lib/VNDB/Util/CommonHTML.pm @@ -82,7 +82,7 @@ sub _menu { txt " (doesn't work yet)"; end; div; - form action => '/nospam?/u/login', id => 'loginform', method => 'post'; + form action => '/u/login', id => 'loginform', method => 'post'; fieldset; legend 'Login'; input type => 'text', class => 'text', id => 'usrname', name => 'usrname'; diff --git a/yawf b/yawf -Subproject f8eb8baf624f04db573cc8e45dff498f97cd1c6 +Subproject 6a266aa61a097a3c4c8849b17a496bc1c273b0f |