Remove login dependency on cookies & referer
[plack-app-gruntmaster.git] / lib / Plack / App / Gruntmaster.pm
index 490fb44e726794c1d6212283650cf5ae81b2b311..7a3dc348b065037ae139a111b2494945a85eb747 100644 (file)
@@ -34,6 +34,7 @@ use constant CONTENT_TYPES => +{
        pas => 'text/x-pascal',
        pl => 'text/x-perl',
        py => 'text/x-python',
+       rb => 'application/x-ruby',
        l => 'text/plain',
 };
 
@@ -48,6 +49,7 @@ use constant FORMAT_EXTENSION => {
        PASCAL => 'pas',
        PERL => 'pl',
        PYTHON => 'py',
+       RUBY => 'rb',
        SBCL => 'l',
 };
 
@@ -138,9 +140,7 @@ sub dispatch_request{
 
                sub (/login) {
                        forbid !remote_user;
-
-                       my $return = $env->{HTTP_REFERER} // '/';
-                       [303, ['Set-Cookie' => "username=".remote_user->id, Location => $return], []]
+                       [200, ['Content-Type' => 'text/plain; charset=UTF-8', 'Cache-Control' => 'private, max-age=300', Vary => 'Authorization'], [$env->{REMOTE_USER}]]
                },
 
                sub (/ct/:contest/log/st) { redirect "/st/$_{contest}" },
@@ -153,6 +153,7 @@ sub dispatch_request{
                },
                sub (/pb/  + ?:owner~&:contest~&:private~)                  {
                        forbid $_{private};
+                       forbid contest && contest->is_pending;
                        response pb => 'Problems', db->problem_list(%_)
                },
 
This page took 0.010726 seconds and 4 git commands to generate.