Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autofill not working properly with template main field #1986

Open
CCerrer opened this issue Jan 24, 2025 · 1 comment
Open

Autofill not working properly with template main field #1986

CCerrer opened this issue Jan 24, 2025 · 1 comment
Labels

Comments

@CCerrer
Copy link

CCerrer commented Jan 24, 2025

Describe the bug

When using the Email template in KeePassDX, autofill seems to ignore the email field and instead uses the Username/Password fields from the default login behavior. This results in incorrect autofill behavior for apps like Disney Plus, Netflix, and websites like Google Accounts or GitHub.

  • Entry without a username: Autofill skips the email field and leaves it blank.
    Image

  • Entry with a username: Autofill prioritizes the username field and ignores the email field.
    Image

To Reproduce

Steps to reproduce the behavior:

  1. go to Settings > Database settings > toggle Template usage. Leave Templates group as default Templates group to create base KeePassDX templates.
  2. at home screen click on "+" at bottom right > Add entry.
  3. on top of the add entry screen change from "Standard" to "Email"
  4. insert any data, like
    1. Title: "Gmail template"
    2. Email address: "foo@gmail.com"
    3. URL: let's use a basic one, "https://google.com/", shold be valid for any subdomain and in any case I could manually select the entry
    4. Password: any
    5. Tags: I don't use
    6. Finish the entry
  5. For double test we create 2 entries, one with an username and one without. So for the second one before change the template you add something at the Standard view to the Username(adding at Email Template view receives an error "the field name already exists") then switch normally to Email template and create the second entry.
  6. go to "https://accounts.google.com/"
    1. on keyboard toolbar click on "Sign in with KeePassDX" > Gmail template. It will appear "Autofill suggestions added" but when you click to fill the form it searchs for an username field than when not found it jumps to the next html element.
    2. click to select another entry > Gmail template(username). It will appear "Autofill suggestions added" but when you click to fill it search for an username then put it instead the email.

Expected behavior

The Email template should autofill the email field when using the "Sign in with KeePassDX" option. Otherwise, it defeats the purpose of the Email template as a functional login method.

Additional Questions

I'm new to KeePass and not entirely sure if I'm misunderstanding how this feature works. Is the Email template intended purely for visual organization, while the Username field remains mandatory for autofill to function correctly?

For example, should I duplicate the email value into the Username field to make autofill work as expected? If that's the case, could you clarify the intended workflow?

On KeePass for Windows, I noticed it’s possible to edit which fields are used during autofill. Does KeePassDX support this, or would I need to rely on plugins for this functionality?

Image

Image

KeePass Database

  • Created with: Same KeePassDX 4.1.1
  • Version: V2 - KDBX3.1
  • Location: Local folder
  • File provider (content:// URI): do not know what is this
  • Size: 2.7kb
  • Contains attachment: No

KeePassDX:

  • Version: 4.1.1
  • Build: Libre
  • Language: English

Android:

  • Device: Samsung Galaxy S23
  • Version: 14

Additional context

Add any other context about the problem here.

  • Browser for Autofill: Firefox 134.0.2
  • App for Autofill: Netflix 8.143.1
  • The issue persists across apps and websites
@CCerrer CCerrer added the bug label Jan 24, 2025
@CCerrer
Copy link
Author

CCerrer commented Jan 25, 2025

I've searched a bit how the KPEntryTemplates works and how KeePassDX uses it and found that the basic templates are missing a key syntax to use the autofill function:

(Using the Email Basic Template as example)
The "main" field at keepassdx is:
[Email address] text

when it is supposed to be:
[Username] text {alias:Email address}

I don't know kotlin but I believe it has to do with:
database\src\main\java\com\kunzisoft\keepass\database\element\template\TemplateBuilder.kt

val email: Template
        get() {
            val sections = mutableListOf<TemplateSection>()
            val mainSection = TemplateSection(mutableListOf<TemplateAttribute>().apply {
                add(emailAddressAttribute)
                add(urlAttribute)
                add(passwordAttribute)
            })
            sections.add(mainSection)
            return Template(
                UUID.randomUUID(),
                TemplateField.LABEL_EMAIL,
                IconImage(IconImageStandard(IconImageStandard.EMAIL_ID)),
                sections)
        }

and:
database\src\main\java\com\kunzisoft\keepass\database\element\template\TemplateAttributeType.kt

enum class TemplateAttributeType(val typeString: String) {
    TEXT("text"),
    LIST("list"),
    DATETIME("datetime"),
    DIVIDER("divider");

    companion object {
        fun getFromString(label: String): TemplateAttributeType {
            return when {
                label.contains(TEXT.typeString, true) -> TEXT
                label.contains(LIST.typeString, true) -> LIST
                label.contains(DATETIME.typeString, true) -> DATETIME
                label.contains(DIVIDER.typeString, true) -> DIVIDER
                else -> TEXT
            }
        }
    }
}

This can be solved locally just by changing the text field inside the template entry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant