Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
83e08c7d
Commit
83e08c7d
authored
Oct 07, 2017
by
Sietse Ringers
Browse files
Fix RemoveAll bug
parent
12492d94
Changes
1
Hide whitespace changes
Inline
Side-by-side
manager.go
View file @
83e08c7d
...
...
@@ -207,7 +207,7 @@ func (cm *CredentialManager) remove(id CredentialTypeIdentifier, index int, stor
// Remove credential
if
creds
,
exists
:=
cm
.
credentials
[
id
];
exists
{
if
_
,
exists
:=
creds
[
index
];
exists
{
creds
[
index
]
=
nil
delete
(
creds
,
index
)
cm
.
credentials
[
id
]
=
creds
}
}
...
...
@@ -244,14 +244,15 @@ func (cm *CredentialManager) RemoveCredentialByHash(hash string) error {
func
(
cm
*
CredentialManager
)
RemoveAllCredentials
()
error
{
removed
:=
map
[
CredentialTypeIdentifier
][]
TranslatedString
{}
list
:=
cm
.
CredentialInfoList
()
for
_
,
cred
:=
range
list
{
id
:=
NewCredentialTypeIdentifier
(
cred
.
CredentialType
ID
)
removed
[
id
]
=
cred
.
Attributes
if
err
:=
cm
.
remove
(
id
,
cred
.
Index
,
false
);
err
!=
nil
{
return
err
for
_
,
attrlistlist
:=
range
cm
.
attributes
{
for
_
,
attrs
:=
range
attrlist
list
{
if
attrs
.
CredentialType
()
!=
nil
{
removed
[
attrs
.
CredentialType
()
.
Identifier
()]
=
attrs
.
Strings
()
}
cm
.
storage
.
DeleteSignature
(
attrs
)
}
}
cm
.
attributes
=
map
[
CredentialTypeIdentifier
][]
*
AttributeList
{}
if
err
:=
cm
.
storage
.
StoreAttributes
(
cm
.
attributes
);
err
!=
nil
{
return
err
}
...
...
@@ -311,8 +312,15 @@ func (cm *CredentialManager) credentialByHash(hash string) (*credential, int, er
}
func
(
cm
*
CredentialManager
)
credentialByID
(
id
CredentialIdentifier
)
(
*
credential
,
error
)
{
cred
,
_
,
err
:=
cm
.
credentialByHash
(
id
.
Hash
)
return
cred
,
err
if
_
,
exists
:=
cm
.
attributes
[
id
.
Type
];
!
exists
{
return
nil
,
nil
}
for
index
,
attrs
:=
range
cm
.
attributes
[
id
.
Type
]
{
if
attrs
.
hash
()
==
id
.
Hash
{
return
cm
.
credential
(
attrs
.
CredentialType
()
.
Identifier
(),
index
)
}
}
return
nil
,
nil
}
// credential returns the requested credential, or nil if we do not have it.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment