package myHive::Model::DB::Authentication;
use Moose;
use namespace::autoclean;
use Data::Dumper;


extends 'myHive::Model::DB';

=head1 NAME

myHive::Model::DB::Authentication - Catalyst Model

=head1 DESCRIPTION

Catalyst Model.

=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

sub checkCredentials {
	my ( $self, %params ) = @_;
        my $where             = $params{where};      
        my ($stmt, @bind)     = $self->{sql}->select( 'account', 'id' ,$where);

        #check to see if we should log
        if ( exists $params{log} && $params{log} == 1 ) {
                print STDERR Dumper($stmt);
                print STDERR Dumper(@bind);
        }
        my $sth = $self->{dbh}->prepare($stmt);
        $sth->execute(@bind);
	my $row = $sth->fetchrow_hashref;
	
        return $row->{id};
	
}

sub checkCredentialsUser {
        my ( $self, %params ) = @_;
        my $where             = $params{where};
        my ($stmt, @bind)     = $self->{sql}->select( 'users', 'account' ,$where);

        #check to see if we should log
        if ( exists $params{log} && $params{log} == 1 ) {
                print STDERR Dumper($stmt);
                print STDERR Dumper(@bind);
        }
        my $sth = $self->{dbh}->prepare($stmt);
        $sth->execute(@bind);
        my $row = $sth->fetchrow_hashref;

        return $row->{account};

}

sub getUserName {
	my ( $self, $account_id) = @_;
	return 'testname';

}



__PACKAGE__->meta->make_immutable;

1;
