implement unpair flow

This commit is contained in:
Michele Balistreri 2021-10-21 08:19:25 +03:00
parent 2b84b6560a
commit 27bf041c5e
No known key found for this signature in database
GPG Key ID: E9567DA33A4F791A
2 changed files with 14 additions and 1 deletions

11
flow.go
View File

@ -237,5 +237,14 @@ func (f *KeycardFlow) unpairThisFlow(kc *keycardContext) (FlowStatus, error) {
return nil, err
}
return nil, errors.New("not yet implemented")
err = kc.unpairCurrent()
if isSCardError(err) {
return nil, restartErr()
} else if err != nil {
return nil, err
}
f.cardInfo.freeSlots++
return FlowStatus{InstanceUID: f.cardInfo.instanceUID, FreeSlots: f.cardInfo.freeSlots}, err
}

View File

@ -360,6 +360,10 @@ func (kc *keycardContext) unpair(index uint8) error {
return nil
}
func (kc *keycardContext) unpairCurrent() error {
return kc.unpair(uint8(kc.cmdSet.PairingInfo.Index))
}
func (kc *keycardContext) getStatusApplication() (*types.ApplicationStatus, error) {
<-kc.connected
if kc.runErr != nil {