Add autocomplete attribute to credential fields

Prevent browsers from automatically autofilling the password entry box
for the Factorio credentials by setting the autocomplete property to
new-password on the password input.
This commit is contained in:
Hornwitser committed 2024-09-18 23:10:31 +02:00
1 parent 44e5847a1d
commit f873f4b369
3 files changed
+13 -3

No files matched your search

+6
View File
@@ -77,6 +77,12 @@ export interface FieldDefinition {
* Text used to describe the config field in user interfaces.
*/
description?: string;
/**
* Value to use for the autocomplete attribute in the Web UI's input element.
* Useful for making browsers behave properly with credential inputs.
* Only used for string and number fields.
*/
autoComplete?: string;
/**
* Web UI component to use for rending this input. Can be extended by
* @{link "@clusterio/web_ui".BaseWebPlugin.inputComponents}
+4
View File
@@ -153,12 +153,14 @@ export class ControllerConfig extends classes.Config<ControllerConfigFields> {
"controller.factorio_username": {
title: "Factorio Username",
description: "Username to authenticate with Factorio API with.",
autoComplete: "section-factorio username",
type: "string",
optional: true,
},
"controller.factorio_token": {
title: "Factorio Token",
description: "Token to authenticate with Factorio API with.",
autoComplete: "section-factorio new-password",
type: "string",
credential: ["controller"],
optional: true,
@@ -276,6 +278,7 @@ export class HostConfig extends classes.Config<HostConfigFields> {
description:
"Username to authenticate with Factorio API with. If set this will be used in the server settings " +
"of all instances on this host.",
autoComplete: "section-factorio username",
type: "string",
optional: true,
},
@@ -284,6 +287,7 @@ export class HostConfig extends classes.Config<HostConfigFields> {
description:
"Token to authenticate with Factorio API with. If set this will be used in the server settings " +
"of all instances on this host.",
autoComplete: "section-factorio new-password",
type: "string",
credential: ["host"],
optional: true,