]> iEval git - plack-app-gruntmaster.git/blobdiff - lib/Plack/App/Gruntmaster.pm
Require authentication and privacy for problems during contests
[plack-app-gruntmaster.git] / lib / Plack / App / Gruntmaster.pm
index 8aab08c2c7e261f50418d9f5454d44fb25baa1a6..136f657028192cd05399dd61c3118ef92109928d 100644 (file)
@@ -151,7 +151,8 @@ sub dispatch_request{
                sub (/login) {
                        forbid !remote_user;
 
-                       [204, ['Set-Cookie' => "username=".remote_user->id], []]
+                       my $return = $env->{HTTP_REFERER} // '/';
+                       [303, ['Set-Cookie' => "username=".remote_user->id, Location => $return], []]
                },
 
                sub (/ct/:contest/log/st) { redirect "/st/$_{contest}" },
@@ -178,6 +179,10 @@ sub dispatch_request{
                        $_{contest} = $contest;
                        return NOT_FOUND if !contest && !problem->is_in_archive || contest && !db->contest_problems->find($_{contest}, $_{problem});
                        forbid problem->is_private;
+                       if (contest && contest->is_running) {
+                               forbid !remote_user;
+                               $privacy = 'private';
+                       }
                        response pb_entry => problem->name, db->problem_entry($_{problem}, $_{contest}, remote_user && remote_user->id);
                },
                sub (/sol/:problem) {
This page took 0.026276 seconds and 4 git commands to generate.