diff --git a/CHANGELOG.md b/CHANGELOG.md index d898c4a6..cb2ef1ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Warn about .ovpn containing potentially unsupported compression. [#16](https://github.com/keeshux/passepartout-ios/issues/16) +- Retain credentials of replaced host profile. ## 1.0 beta 1107 (2018-10-26) diff --git a/Passepartout-iOS/Scenes/Organizer/WizardHostViewController.swift b/Passepartout-iOS/Scenes/Organizer/WizardHostViewController.swift index 3c7531db..6b90f34d 100644 --- a/Passepartout-iOS/Scenes/Organizer/WizardHostViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/WizardHostViewController.swift @@ -108,22 +108,27 @@ class WizardHostViewController: UITableViewController, TableModelHost, Wizard { let profile = HostConnectionProfile(title: enteredTitle, hostname: file.hostname) profile.parameters = file.configuration - guard !TransientStore.shared.service.containsProfile(profile) else { + let service = TransientStore.shared.service + guard !service.containsProfile(profile) else { + let replacedProfile = service.profile(withContext: profile.context, id: profile.id) let alert = Macros.alert(title, L10n.Wizards.Host.Alerts.Existing.message) alert.addDefaultAction(L10n.Global.ok) { - self.next(withProfile: profile) + self.next(withProfile: profile, replacedProfile: replacedProfile) } alert.addCancelAction(L10n.Global.cancel) present(alert, animated: true, completion: nil) return } - next(withProfile: profile) + next(withProfile: profile, replacedProfile: nil) } - private func next(withProfile profile: HostConnectionProfile) { + private func next(withProfile profile: HostConnectionProfile, replacedProfile: ConnectionProfile?) { createdProfile = profile let accountVC = StoryboardScene.Main.accountIdentifier.instantiate() + if let replacedProfile = replacedProfile { + accountVC.currentCredentials = TransientStore.shared.service.credentials(for: replacedProfile) + } accountVC.delegate = self navigationController?.pushViewController(accountVC, animated: true) }