Add UI master key setup and change flows
This commit is contained in:
@@ -32,6 +32,11 @@ type LockableSession interface {
|
||||
Unlock(vault.MasterKey) error
|
||||
}
|
||||
|
||||
type MasterKeyChangeableSession interface {
|
||||
CurrentSession
|
||||
ChangeMasterKey(vault.MasterKey) error
|
||||
}
|
||||
|
||||
type SaveableSession interface {
|
||||
CurrentSession
|
||||
Save() error
|
||||
@@ -419,6 +424,20 @@ func (s *State) Unlock(key vault.MasterKey) error {
|
||||
return session.Unlock(key)
|
||||
}
|
||||
|
||||
func (s *State) ChangeMasterKey(key vault.MasterKey) error {
|
||||
session, ok := s.Session.(MasterKeyChangeableSession)
|
||||
if !ok {
|
||||
return fmt.Errorf("session does not support master key changes")
|
||||
}
|
||||
|
||||
if err := session.ChangeMasterKey(key); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s.Dirty = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *State) EnterGroup(name string) {
|
||||
s.CurrentPath = append(append([]string(nil), s.CurrentPath...), name)
|
||||
s.SelectedEntryID = ""
|
||||
|
||||
Reference in New Issue
Block a user