summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/signinedit.pm
blob: 321c93ed522141ad6a11f7d14b5ed7a1a3fa2354 (plain)
  1. #!/usr/bin/perl
  2. package IkiWiki::Plugin::signinedit;
  3. use warnings;
  4. use strict;
  5. use IkiWiki 2.00;
  6. sub import {
  7. hook(type => "getsetup", id => "signinedit", call => \&getsetup);
  8. hook(type => "canedit", id => "signinedit", call => \&canedit,
  9. last => 1);
  10. }
  11. sub getsetup () {
  12. return
  13. plugin => {
  14. safe => 1,
  15. rebuild => 0,
  16. },
  17. }
  18. sub canedit ($$$) {
  19. my $page=shift;
  20. my $cgi=shift;
  21. my $session=shift;
  22. # Have the user sign in, if they are not already. This is why the
  23. # hook runs last, so that any hooks that don't need the user to
  24. # signin can override this.
  25. if (! defined $session->param("name") ||
  26. ! IkiWiki::userinfo_get($session->param("name"), "regdate")) {
  27. return sub { IkiWiki::needsignin($cgi, $session) };
  28. }
  29. else {
  30. return "";
  31. }
  32. }
  33. 1