mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 07:33:12 +09:00
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:
1 parent
44e5847a1d
commit
f873f4b369
3 files changed
+13
-3
No files matched your search
@@ -77,6 +77,12 @@ export interface FieldDefinition {
|
|||||||
* Text used to describe the config field in user interfaces.
|
* Text used to describe the config field in user interfaces.
|
||||||
*/
|
*/
|
||||||
description?: string;
|
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
|
* Web UI component to use for rending this input. Can be extended by
|
||||||
* @{link "@clusterio/web_ui".BaseWebPlugin.inputComponents}
|
* @{link "@clusterio/web_ui".BaseWebPlugin.inputComponents}
|
||||||
|
|||||||
@@ -153,12 +153,14 @@ export class ControllerConfig extends classes.Config<ControllerConfigFields> {
|
|||||||
"controller.factorio_username": {
|
"controller.factorio_username": {
|
||||||
title: "Factorio Username",
|
title: "Factorio Username",
|
||||||
description: "Username to authenticate with Factorio API with.",
|
description: "Username to authenticate with Factorio API with.",
|
||||||
|
autoComplete: "section-factorio username",
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
"controller.factorio_token": {
|
"controller.factorio_token": {
|
||||||
title: "Factorio Token",
|
title: "Factorio Token",
|
||||||
description: "Token to authenticate with Factorio API with.",
|
description: "Token to authenticate with Factorio API with.",
|
||||||
|
autoComplete: "section-factorio new-password",
|
||||||
type: "string",
|
type: "string",
|
||||||
credential: ["controller"],
|
credential: ["controller"],
|
||||||
optional: true,
|
optional: true,
|
||||||
@@ -276,6 +278,7 @@ export class HostConfig extends classes.Config<HostConfigFields> {
|
|||||||
description:
|
description:
|
||||||
"Username to authenticate with Factorio API with. If set this will be used in the server settings " +
|
"Username to authenticate with Factorio API with. If set this will be used in the server settings " +
|
||||||
"of all instances on this host.",
|
"of all instances on this host.",
|
||||||
|
autoComplete: "section-factorio username",
|
||||||
type: "string",
|
type: "string",
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
@@ -284,6 +287,7 @@ export class HostConfig extends classes.Config<HostConfigFields> {
|
|||||||
description:
|
description:
|
||||||
"Token to authenticate with Factorio API with. If set this will be used in the server settings " +
|
"Token to authenticate with Factorio API with. If set this will be used in the server settings " +
|
||||||
"of all instances on this host.",
|
"of all instances on this host.",
|
||||||
|
autoComplete: "section-factorio new-password",
|
||||||
type: "string",
|
type: "string",
|
||||||
credential: ["host"],
|
credential: ["host"],
|
||||||
optional: true,
|
optional: true,
|
||||||
|
|||||||
@@ -44,12 +44,12 @@ function renderInput(inputComponents: Record<string, InputComponent>, def: lib.F
|
|||||||
}
|
}
|
||||||
if (def.type === "string") {
|
if (def.type === "string") {
|
||||||
if (def.credential) {
|
if (def.credential) {
|
||||||
return <Input.Password/>;
|
return <Input.Password autoComplete={def.autoComplete} />;
|
||||||
}
|
}
|
||||||
return <Input/>;
|
return <Input autoComplete={def.autoComplete} />;
|
||||||
}
|
}
|
||||||
if (def.type === "number") {
|
if (def.type === "number") {
|
||||||
return <InputNumber/>;
|
return <InputNumber autoComplete={def.autoComplete} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `Unknown type ${def.type}`;
|
return `Unknown type ${def.type}`;
|
||||||
|
|||||||
Reference in new issue
Block a user