Return HTTPS URI username from CredentialsProvider (#1049)

Let the PasswordFinderCredentialsProvider support Username as a
CredentialItem type and return the user part of the repository URI when
it is requested.
This commit is contained in:
Fabian Henneke 2020-08-24 09:11:40 +02:00 committed by GitHub
parent 2c8999c1bf
commit 679037b81d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -57,6 +57,7 @@ abstract class GitOperation(gitDir: File, internal val callingActivity: Fragment
override fun get(uri: URIish?, vararg items: CredentialItem): Boolean { override fun get(uri: URIish?, vararg items: CredentialItem): Boolean {
for (item in items) { for (item in items) {
when (item) { when (item) {
is CredentialItem.Username -> item.value = uri?.user
is CredentialItem.Password -> item.value = passwordFinder.reqPassword(null) is CredentialItem.Password -> item.value = passwordFinder.reqPassword(null)
else -> UnsupportedCredentialItem(uri, item.javaClass.name) else -> UnsupportedCredentialItem(uri, item.javaClass.name)
} }
@ -65,7 +66,7 @@ abstract class GitOperation(gitDir: File, internal val callingActivity: Fragment
} }
override fun supports(vararg items: CredentialItem) = items.all { override fun supports(vararg items: CredentialItem) = items.all {
it is CredentialItem.Password it is CredentialItem.Username || it is CredentialItem.Password
} }
} }