Confirm before overwriting OTP settings in the password cell
This commit is contained in:
parent
0f9b95eaa9
commit
bd3ed7d5e5
2 changed files with 21 additions and 2 deletions
|
|
@ -126,7 +126,23 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl
|
|||
}
|
||||
|
||||
// generate password, copy to pasteboard, and set the cell
|
||||
// check whether the current password looks like an OTP field
|
||||
func generateAndCopyPassword() {
|
||||
if let currentPassword = fillPasswordCell?.getContent(),
|
||||
Password.LooksLikeOTP(line: currentPassword) {
|
||||
let alert = UIAlertController(title: "Overwrite?", message: "Overwrite the one-time password configuration?", preferredStyle: UIAlertControllerStyle.alert)
|
||||
alert.addAction(UIAlertAction(title: "Yes", style: UIAlertActionStyle.destructive, handler: {_ in
|
||||
self.generateAndCopyPasswordNoOtpCheck()
|
||||
}))
|
||||
alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.cancel, handler: nil))
|
||||
self.present(alert, animated: true, completion: nil)
|
||||
} else {
|
||||
self.generateAndCopyPasswordNoOtpCheck()
|
||||
}
|
||||
}
|
||||
|
||||
// generate the password, don't care whether the original line is otp
|
||||
func generateAndCopyPasswordNoOtpCheck() {
|
||||
// show password settings (e.g., the length slider)
|
||||
if hidePasswordSettings == true {
|
||||
hidePasswordSettings = false
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class Password {
|
|||
|
||||
// check whether the first line of the plainText looks like an otp entry
|
||||
let (key, value) = Password.getKeyValuePair(from: plainTextSplit[0])
|
||||
if key != nil && Password.otpKeywords.contains(key!) {
|
||||
if Password.otpKeywords.contains(key ?? "") {
|
||||
firstLineIsOTPField = true
|
||||
self.additions[key!] = value
|
||||
self.additionKeys.insert(key!, at: 0)
|
||||
|
|
@ -304,5 +304,8 @@ class Password {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static func LooksLikeOTP(line: String) -> Bool {
|
||||
let (key, _) = getKeyValuePair(from: line)
|
||||
return Password.otpKeywords.contains(key ?? "")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue