2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-17 11:26:03 +00:00

lib/FHEM/Core/Authentication/Passwords.pm: fix rename bug, new method to create object

git-svn-id: https://svn.fhem.de/fhem/trunk@24312 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
LeonGaultier 2021-04-23 00:52:05 +00:00
parent 02b579f75b
commit 5f30363026
2 changed files with 21 additions and 12 deletions

View File

@ -1,5 +1,8 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
- bugfix: lib/FHEM/Core/Authentication/Passwords.pm:
fix rename bug, new method to create object
You musst pass a instance TYPE to the function if you create a objekt
- change: move lib/FHEM/Core/Password/Utils.pm to
lib/FHEM/Core/Authentication/Passwords.pm
- feature: 30_HUEBridge: enable autocreation of sensors for deconz

View File

@ -32,6 +32,8 @@ use 5.008;
use strict;
use warnings;
our $VERSION = 1.0;
### eigene Funktionen exportieren
require Exporter;
@ -57,10 +59,11 @@ our %EXPORT_TAGS = (
sub new {
my $class = shift;
my $self = {
name => undef,
};
my $class = shift;
my $type = shift;
my $self = {
TYPE => $type,
};
bless $self, $class;
return $self;
@ -71,7 +74,7 @@ sub setStorePassword {
my $name = shift;
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 $salt = substr(sprintf("%08X", rand($y)*rand($x)),0,8);
my $key = ::getUniqueId() . $index . $salt;
@ -104,7 +107,7 @@ sub setDeletePassword {
my $name = shift;
my $err;
$err = ::setKeyValue( $::defs{$name}->{TYPE} . '_' . $name . '_passkey', undef );
$err = ::setKeyValue( $self->{TYPE} . '_' . $name . '_passkey', undef );
return(undef,$err)
if ( defined($err) );
@ -116,7 +119,7 @@ sub getReadPassword {
my $self = shift;
my $name = shift;
my $index = $::defs{$name}->{TYPE} . '_' . $name . '_passkey';
my $index = $self->{TYPE} . '_' . $name . '_passkey';
my ( $password, $err, $salt );
::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
This document describes FHEM::Core::Authentication::Passwords version 0.9
This document describes FHEM::Core::Authentication::Passwords version 1.0
=head1 CONSTRUCTOR
FHEM::Core::Authentication::Passwords->new();
FHEM::Core::Authentication::Passwords->new(<INSTANZTYPE>);
=head1 SYNOPSIS
@ -213,13 +216,16 @@ FHEM::Core::Authentication::Passwords->new();
=head1 DESCRIPTION
Store new Password
$hash->{helper}->{passwdobj}->setStorePassword('PASSWORD');
$hash->{helper}->{passwdobj}->setStorePassword($name,'PASSWORD');
Read Password
$hash->{helper}->{passwdobj}->getReadPassword();
$hash->{helper}->{passwdobj}->getReadPassword($name);
Delete Password
$hash->{helper}->{passwdobj}->setDeletePassword($name);
Rename Password
$hash->{helper}->{passwdobj}->getRename($newname,$oldname);
=head1 EXPORT