change object deklaration

You musst pass a variable to the function if you create a objekt
This commit is contained in:
Marko Oldenburg 2021-04-23 02:41:48 +02:00
parent 3f1ab3b652
commit 8414fce32c
2 changed files with 13 additions and 10 deletions

View File

@ -1 +1 @@
UPD 2021-04-22_08:40:31 5929 lib/FHEM/Core/Authentication/Passwords.pm UPD 2021-04-23_02:41:23 5969 lib/FHEM/Core/Authentication/Passwords.pm

View File

@ -32,6 +32,8 @@ use 5.008;
use strict; use strict;
use warnings; use warnings;
our $VERSION = 1.0;
### eigene Funktionen exportieren ### eigene Funktionen exportieren
require Exporter; require Exporter;
@ -58,8 +60,9 @@ our %EXPORT_TAGS = (
sub new { sub new {
my $class = shift; my $class = shift;
my $type = shift;
my $self = { my $self = {
name => undef, TYPE => $type,
}; };
bless $self, $class; bless $self, $class;
@ -71,7 +74,7 @@ sub setStorePassword {
my $name = shift; my $name = shift;
my $password = shift // return(undef,q{no password given}); my $password = shift // return(undef,q{no password given});
my $index = $::defs{$name}->{TYPE} . '_' . $name . '_passkey'; my $index = $self->{TYPE} . '_' . $name . '_passkey';
my ($x,$y) = ::gettimeofday(); my ($x,$y) = ::gettimeofday();
my $salt = substr(sprintf("%08X", rand($y)*rand($x)),0,8); my $salt = substr(sprintf("%08X", rand($y)*rand($x)),0,8);
my $key = ::getUniqueId() . $index . $salt; my $key = ::getUniqueId() . $index . $salt;
@ -104,7 +107,7 @@ sub setDeletePassword {
my $name = shift; my $name = shift;
my $err; my $err;
$err = ::setKeyValue( $::defs{$name}->{TYPE} . '_' . $name . '_passkey', undef ); $err = ::setKeyValue( $self->{TYPE} . '_' . $name . '_passkey', undef );
return(undef,$err) return(undef,$err)
if ( defined($err) ); if ( defined($err) );
@ -116,7 +119,7 @@ sub getReadPassword {
my $self = shift; my $self = shift;
my $name = shift; my $name = shift;
my $index = $::defs{$name}->{TYPE} . '_' . $name . '_passkey'; my $index = $self->{TYPE} . '_' . $name . '_passkey';
my ( $password, $err, $salt ); my ( $password, $err, $salt );
::Log3($name, 4, qq{password Keystore handle for Device ($name) - Read password from file}); ::Log3($name, 4, qq{password Keystore handle for Device ($name) - Read password from file});
@ -196,11 +199,11 @@ FHEM::Core::Authentication::Passwords - FHEM extension for password handling
=head1 VERSION =head1 VERSION
This document describes FHEM::Core::Authentication::Passwords version 0.9 This document describes FHEM::Core::Authentication::Passwords version 1.0
=head1 CONSTRUCTOR =head1 CONSTRUCTOR
FHEM::Core::Authentication::Passwords->new(); FHEM::Core::Authentication::Passwords->new(<INSTANZTYPE>);
=head1 SYNOPSIS =head1 SYNOPSIS