Persist vault binding refs in recent remotes
This commit is contained in:
@@ -152,10 +152,13 @@ type recentVaultRecord struct {
|
||||
}
|
||||
|
||||
type recentRemoteRecord struct {
|
||||
BaseURL string `json:"baseUrl"`
|
||||
Path string `json:"path"`
|
||||
LastGroup []string `json:"lastGroup,omitempty"`
|
||||
UsedAt string `json:"usedAt,omitempty"`
|
||||
BaseURL string `json:"baseUrl"`
|
||||
Path string `json:"path"`
|
||||
LocalVaultPath string `json:"localVaultPath,omitempty"`
|
||||
RemoteProfileID string `json:"remoteProfileId,omitempty"`
|
||||
CredentialEntryID string `json:"credentialEntryId,omitempty"`
|
||||
LastGroup []string `json:"lastGroup,omitempty"`
|
||||
UsedAt string `json:"usedAt,omitempty"`
|
||||
}
|
||||
|
||||
type uiPreferences struct {
|
||||
@@ -1077,21 +1080,23 @@ func (u *ui) openRemoteAction() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if binding, resolved, ok, err := u.resolvedSelectedVaultRemoteBinding(); err != nil {
|
||||
return err
|
||||
} else if ok {
|
||||
if err := u.state.OpenBoundRemoteVault(binding, key); err != nil {
|
||||
if u.hasOpenVault() {
|
||||
if binding, resolved, ok, err := u.resolvedSelectedVaultRemoteBinding(); err != nil {
|
||||
return err
|
||||
} else if ok {
|
||||
if err := u.state.OpenBoundRemoteVault(binding, key); err != nil {
|
||||
return err
|
||||
}
|
||||
u.remoteBaseURL.SetText(resolved.Profile.BaseURL)
|
||||
u.remotePath.SetText(resolved.Profile.Path)
|
||||
u.noteRecentRemote(resolved.Profile.BaseURL, resolved.Profile.Path)
|
||||
u.resetPasswordPeek()
|
||||
u.restoreRecentRemoteGroup(resolved.Profile.BaseURL, resolved.Profile.Path)
|
||||
u.loadSecuritySettingsFromSession()
|
||||
u.editingEntry = false
|
||||
u.filter()
|
||||
return nil
|
||||
}
|
||||
u.remoteBaseURL.SetText(resolved.Profile.BaseURL)
|
||||
u.remotePath.SetText(resolved.Profile.Path)
|
||||
u.noteRecentRemote(resolved.Profile.BaseURL, resolved.Profile.Path)
|
||||
u.resetPasswordPeek()
|
||||
u.restoreRecentRemoteGroup(resolved.Profile.BaseURL, resolved.Profile.Path)
|
||||
u.loadSecuritySettingsFromSession()
|
||||
u.editingEntry = false
|
||||
u.filter()
|
||||
return nil
|
||||
}
|
||||
client := webdav.Client{
|
||||
BaseURL: strings.TrimSpace(u.remoteBaseURL.Text()),
|
||||
@@ -1132,19 +1137,21 @@ func (u *ui) startOpenRemoteAction() {
|
||||
Password: u.remotePassword.Text(),
|
||||
}
|
||||
remotePath := strings.TrimSpace(u.remotePath.Text())
|
||||
if _, resolved, ok, err := u.resolvedSelectedVaultRemoteBinding(); err != nil {
|
||||
u.state.ErrorMessage = u.describeActionError("open remote vault", err)
|
||||
u.requestMasterPassFocus = true
|
||||
return
|
||||
} else if ok {
|
||||
client = webdav.Client{
|
||||
BaseURL: resolved.Profile.BaseURL,
|
||||
Username: resolved.Credentials.Username,
|
||||
Password: resolved.Credentials.Password,
|
||||
if u.hasOpenVault() {
|
||||
if _, resolved, ok, err := u.resolvedSelectedVaultRemoteBinding(); err != nil {
|
||||
u.state.ErrorMessage = u.describeActionError("open remote vault", err)
|
||||
u.requestMasterPassFocus = true
|
||||
return
|
||||
} else if ok {
|
||||
client = webdav.Client{
|
||||
BaseURL: resolved.Profile.BaseURL,
|
||||
Username: resolved.Credentials.Username,
|
||||
Password: resolved.Credentials.Password,
|
||||
}
|
||||
remotePath = resolved.Profile.Path
|
||||
u.remoteBaseURL.SetText(resolved.Profile.BaseURL)
|
||||
u.remotePath.SetText(resolved.Profile.Path)
|
||||
}
|
||||
remotePath = resolved.Profile.Path
|
||||
u.remoteBaseURL.SetText(resolved.Profile.BaseURL)
|
||||
u.remotePath.SetText(resolved.Profile.Path)
|
||||
}
|
||||
u.lastLifecycleAction = "open remote vault"
|
||||
u.runBackgroundAction("open remote vault", func() (func() error, error) {
|
||||
@@ -1518,6 +1525,9 @@ func (u *ui) loadRecentRemotes() {
|
||||
for _, record := range records {
|
||||
record.BaseURL = strings.TrimSpace(record.BaseURL)
|
||||
record.Path = strings.TrimSpace(record.Path)
|
||||
record.LocalVaultPath = strings.TrimSpace(record.LocalVaultPath)
|
||||
record.RemoteProfileID = strings.TrimSpace(record.RemoteProfileID)
|
||||
record.CredentialEntryID = strings.TrimSpace(record.CredentialEntryID)
|
||||
if record.BaseURL == "" || record.Path == "" {
|
||||
continue
|
||||
}
|
||||
@@ -1750,6 +1760,11 @@ func (u *ui) noteRecentRemote(baseURL, path string) {
|
||||
LastGroup: append([]string(nil), u.currentPath...),
|
||||
UsedAt: u.now().Format(time.RFC3339Nano),
|
||||
}
|
||||
if binding, ok := u.selectedVaultRemoteBinding(); ok {
|
||||
record.LocalVaultPath = binding.LocalVaultPath
|
||||
record.RemoteProfileID = binding.RemoteProfileID
|
||||
record.CredentialEntryID = binding.CredentialEntryID
|
||||
}
|
||||
if len(record.LastGroup) == 0 {
|
||||
record.LastGroup = u.recentRemoteGroup(baseURL, path)
|
||||
}
|
||||
@@ -1905,6 +1920,9 @@ func (u *ui) selectedRecentRemoteRecord() (recentRemoteRecord, bool) {
|
||||
func (u *ui) applyRecentRemoteRecord(record recentRemoteRecord) {
|
||||
u.remoteBaseURL.SetText(record.BaseURL)
|
||||
u.remotePath.SetText(record.Path)
|
||||
u.vaultPath.SetText(strings.TrimSpace(record.LocalVaultPath))
|
||||
u.selectedVaultRemoteProfileID = strings.TrimSpace(record.RemoteProfileID)
|
||||
u.selectedVaultRemoteCredentialEntryID = strings.TrimSpace(record.CredentialEntryID)
|
||||
u.remotePassword.Mask = '•'
|
||||
u.selectedRemoteConnection = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user