App-RPi-EnvUI

 view release on metacpan or  search on metacpan

lib/App/RPi/EnvUI/API.pm  view on Meta::CPAN

    }

    if (! defined $pw){
        confess "\n\nauth() requires a password sent in\n\n";

    }
    my $csh = Crypt::SaltedHash->new(algorithm => 'SHA1');

    my $crypted = $self->db->user($user)->{pass};

    return $csh->validate($crypted, $pw);
}
sub events {
    my $self = shift;

    my $log = $log->child('events');

    $events = App::RPi::EnvUI::Event->new($self->testing);

    $self->{events}{env_to_db} = $events->env_to_db;
    $self->{events}{env_action} = $events->env_action;

lib/App/RPi/EnvUI/API.pm  view on Meta::CPAN

By default, this will be C<aux1>.

=head2 auth($user, $pw)

Checks whether a user is supplying the correct password.

Parameters:

    $user

Mandatory, String. The user name to validate the password for.

    $pw

Mandatory, String. The plain text password to verify.


Return: True (C<1>) if successful, C<undef> otherwise.

=head2 aux($aux_id)

t/13-api_base.t  view on Meta::CPAN

    is $dht_new_sub->called, 1, "RPi::DHT11->new is called by _prod_mode()";
    is ref $api->sensor, 'RPi::DHT11', "_prod_mode() generates a sensor";
}

{ # passwd()

    my $pw = 'admin';
    my $enc = $api->passwd($pw);

    my $csh = Crypt::SaltedHash->new(algorithm => 'SHA1');
    is $csh->validate($enc, $pw), 1, "passwd() returns an ok crypted pw";

    my $ok = eval { $api->passwd; 1; };
    is $ok, undef, "passwd() requires a password sent in";
    like $@, qr/plain text password/, "...and error is ok";
}

{ # auth()

    my $un = 'admin';
    my $pw = 'admin';



( run in 0.237 second using v1.01-cache-2.11-cpan-4d50c553e7e )