Minor bug fixes when parsing Vault
https://git.n64.cc/nosial/ncc/-/issues/27
This commit is contained in:
parent
f1e7aeccfa
commit
5a83a7f6fe
3 changed files with 7 additions and 8 deletions
|
@ -96,8 +96,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$VaultArray = ZiProto::decode(IO::fread($this->CredentialsPath));
|
$VaultArray = ZiProto::decode(IO::fread($this->CredentialsPath));
|
||||||
$VaultObject = new Vault();
|
$VaultObject = Vault::fromArray($VaultArray);
|
||||||
$VaultObject->fromArray($VaultArray);
|
|
||||||
|
|
||||||
if($VaultObject->Version !== Versions::CredentialsStoreVersion)
|
if($VaultObject->Version !== Versions::CredentialsStoreVersion)
|
||||||
throw new RuntimeException('Credentials store version mismatch');
|
throw new RuntimeException('Credentials store version mismatch');
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
namespace ncc\Objects;
|
namespace ncc\Objects;
|
||||||
|
|
||||||
use ncc\Abstracts\AuthenticationType;
|
use ncc\Abstracts\AuthenticationType;
|
||||||
|
use ncc\Abstracts\Versions;
|
||||||
use ncc\Exceptions\RuntimeException;
|
use ncc\Exceptions\RuntimeException;
|
||||||
use ncc\Interfaces\PasswordInterface;
|
use ncc\Interfaces\PasswordInterface;
|
||||||
use ncc\Objects\Vault\Entry;
|
use ncc\Objects\Vault\Entry;
|
||||||
|
@ -31,6 +32,7 @@
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
$this->Version = Versions::CredentialsStoreVersion;
|
||||||
$this->Entries = [];
|
$this->Entries = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,12 +182,10 @@
|
||||||
$vault = new Vault();
|
$vault = new Vault();
|
||||||
$vault->Version = Functions::array_bc($array, 'version');
|
$vault->Version = Functions::array_bc($array, 'version');
|
||||||
$entries = Functions::array_bc($array, 'entries');
|
$entries = Functions::array_bc($array, 'entries');
|
||||||
|
$vault->Entries = [];
|
||||||
|
|
||||||
foreach($entries as $entry)
|
foreach($entries as $entry)
|
||||||
{
|
$vault->Entries[] = Entry::fromArray($entry);
|
||||||
$entry = Entry::fromArray($entry);
|
|
||||||
$vault->Entries[] = $entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $vault;
|
return $vault;
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,8 +261,8 @@
|
||||||
|
|
||||||
$self->Name = Functions::array_bc($data, 'name');
|
$self->Name = Functions::array_bc($data, 'name');
|
||||||
$self->Encrypted = Functions::array_bc($data, 'encrypted');
|
$self->Encrypted = Functions::array_bc($data, 'encrypted');
|
||||||
|
|
||||||
$password = Functions::array_bc($data, 'password');
|
$password = Functions::array_bc($data, 'password');
|
||||||
|
|
||||||
if($password !== null)
|
if($password !== null)
|
||||||
{
|
{
|
||||||
if($self->Encrypted)
|
if($self->Encrypted)
|
||||||
|
@ -272,7 +272,7 @@
|
||||||
}
|
}
|
||||||
elseif(gettype($password) == 'array')
|
elseif(gettype($password) == 'array')
|
||||||
{
|
{
|
||||||
$self->Password = match (Functions::array_bc($data, 'authentication_type'))
|
$self->Password = match (Functions::array_bc($password, 'authentication_type'))
|
||||||
{
|
{
|
||||||
AuthenticationType::UsernamePassword => UsernamePassword::fromArray($password),
|
AuthenticationType::UsernamePassword => UsernamePassword::fromArray($password),
|
||||||
AuthenticationType::AccessToken => AccessToken::fromArray($password)
|
AuthenticationType::AccessToken => AccessToken::fromArray($password)
|
||||||
|
|
Loading…
Add table
Reference in a new issue