<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package myHive::Controller::Rest::XML;
use Moose;
use namespace::autoclean;
use Data::Dumper;

BEGIN {extends 'Catalyst::Controller'; }

=head1 NAME

myHive::Controller::Rest::XML - Catalyst Controller

=head1 DESCRIPTION

Catalyst Controller.

=head1 METHODS

=cut

sub begin : Private {
        my ( $self, $c ) = @_;
	
        $c-&gt;config-&gt;{session}-&gt;{'Catalyst::Plugin::Session'} = 'bug';#horrible
        $c-&gt;{authentication}    = myHive::Model::Authentication-&gt;new;
        $c-&gt;{landowner}         = myHive::Model::Landowner::Manager-&gt;new;
        $c-&gt;{area}              = myHive::Model::Area::Manager-&gt;new;


        return;
}



=head2 index

=cut

sub index :Path :Args(0) {
    my ( $self, $c ) = @_;

    $c-&gt;response-&gt;body('Matched myHive::Controller::Rest::XML in Rest::XML.');
}

sub authenticate : Local : Args() {
	my ( $self, $c ) = @_;
	my $username = $c-&gt;request-&gt;query_parameters-&gt;{username};
	my $password = $c-&gt;request-&gt;query_parameters-&gt;{password};
	
	if ( !exists  $c-&gt;session-&gt;{account_id} ) {
		 my $account_id = $c-&gt;{authentication}-&gt;checkUserCredentials(
                                        username =&gt; $username,
                                        password =&gt; $password,
                                );
		 print STDERR "account id: $account_id";
		 if ( $account_id )  {
                        $c-&gt;session(
                                {
                                        loggedin        =&gt; 'yes',
                                        username        =&gt;  $username,
                                        account_id      =&gt;  $account_id,
					seed		=&gt;  $c-&gt;generate_session_id,
                                        expires         =&gt;  5
                                }
                        );
		}                       
	
			
	}

	$c-&gt;stash-&gt;{seed} =  $c-&gt;session-&gt;{seed} || 'failed';
	$c-&gt;stash-&gt;{template} = 'rest/authentication.tt';
	return;
}


sub getAreas : Local : Args(1) {
	my ( $self, $c,$seed ) = @_;
	if ( $seed eq $c-&gt;session-&gt;{seed} ) {
		$c-&gt;stash-&gt;{areas} = $c-&gt;{area}-&gt;getAreas( account =&gt; $c-&gt;session-&gt;{account_id} );
	}
	$c-&gt;stash-&gt;{template} = 'rest/areas.tt';
	return; 
	#check seed
	#my %params = $c-&gt;rw
	#unless ( $c-&gt;{areas} ) {
	#	#$c-&gt;{areas} = myHive::Model::Areas::Manager-&gt;new;
	#}
	#$c-&gt;{areas}-&gt;getAreas( 
	#return;
}





=head1 AUTHOR

root

=head1 LICENSE

This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.

=cut

__PACKAGE__-&gt;meta-&gt;make_immutable;

1;
</pre></body></html>