summaryrefslogtreecommitdiff
path: root/scripts/login.pl
blob: 39482b65f802956d0570861912f60d8475ea11dc (plain)
  1. package LedgerSMB::Scripts::login;
  2. our $VERSION = 1.0;
  3. use LedgerSMB::Locale;
  4. use LedgerSMB::Form; # Required for now to integrate with menu module.
  5. use LedgerSMB::User;
  6. use strict;
  7. sub __default {
  8. my ($request) = @_;
  9. my $locale;
  10. $locale = LedgerSMB::Locale->get_handle(${LedgerSMB::Sysconfig::language})
  11. or $request->error( __FILE__ . ':' . __LINE__ .
  12. ": Locale not loaded: $!\n" );
  13. my $template = LedgerSMB::Template->new(
  14. user =>$request->{_user},
  15. locale => $locale,
  16. path => 'UI',
  17. template => 'login',
  18. format => 'HTML'
  19. );
  20. $template->render($request);
  21. }
  22. sub login {
  23. my ($request) = @_;
  24. if (!$request->{_user}){
  25. __default($request);
  26. }
  27. require "scripts/menu.pl";
  28. LedgerSMB::Scripts::menu::root_doc($request);
  29. }
  30. sub logout {
  31. my ($request) = @_;
  32. $request->{callback} = "";
  33. $request->{endsession} = 1;
  34. Session::session_destroy($request);
  35. print "Location: login.pl\n";
  36. print "Content-type: text/html\n\n";
  37. exit;
  38. }
  39. 1;