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