package AppUser::Logout::Command::Logout;

use strict;
use warnings;

use lib '/app/tools/common/lib';
use RSApache::Response::XSLT;
use RSApache::RSWebApp;
use base 'RSApache::Command';

use constant kTemplate => '/app/tools/appuser/templates/logout.xsl';

sub cmd  { return "logout"; }
sub area { return "rps"; }

sub execute {
    my ($self) = @_;

    # are they already logged out?
    my $session = RSApache::RSWebApp::GetSession();
    if ( $session->IsValid() ) {
        if ( $session->End() ) {

            # print STDERR "session ended\n";
        } else {

            # print STDERR "session end failed: ".$session->errstr."\n";
        }
    }

    return RSApache::Response::XSLT->new( $self->{xml}, kTemplate );
}

###
1;    # Play nicely.
###
