fix #488 - support user field for completion

- a few other backends use `user` instead of `username` or `login`
  (e.g. gopass-jsonapi, keepass2csv importer, fpm2 importer)
- shorter to type when extracting field separately (e.g. CLI/clipboard) tools
This commit is contained in:
Martin Nowak 2023-01-21 16:52:46 +01:00 committed by Mingshen Sun
parent 51ad0c2920
commit 3ab334dd00
5 changed files with 15 additions and 2 deletions

View file

@ -51,6 +51,10 @@ public class Password {
getAdditionValue(withKey: Constants.USERNAME_KEYWORD)
}
public var user: String? {
getAdditionValue(withKey: Constants.USER_KEYWORD)
}
public var login: String? {
getAdditionValue(withKey: Constants.LOGIN_KEYWORD)
}
@ -121,6 +125,7 @@ public class Password {
additions.filter { field in
let title = field.title.lowercased()
return title != Constants.USERNAME_KEYWORD
&& title != Constants.USER_KEYWORD
&& title != Constants.LOGIN_KEYWORD
&& title != Constants.PASSWORD_KEYWORD
&& (!Constants.isUnknown(title) || !Defaults.isHideUnknownOn)
@ -215,6 +220,6 @@ public class Password {
}
public func getUsernameForCompletion() -> String {
username ?? login ?? nameFromPath ?? ""
username ?? user ?? login ?? nameFromPath ?? ""
}
}