stages/prompt: add text_read_only field
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
ed6659a46d
commit
da74304221
|
@ -26,6 +26,10 @@ class FieldTypes(models.TextChoices):
|
||||||
|
|
||||||
# Simple text field
|
# Simple text field
|
||||||
TEXT = "text", _("Text: Simple Text input")
|
TEXT = "text", _("Text: Simple Text input")
|
||||||
|
# Simple text field
|
||||||
|
TEXT_READ_ONLY = "text_read_only", _(
|
||||||
|
"Text (read-only): Simple Text input, but cannot be edited."
|
||||||
|
)
|
||||||
# Same as text, but has autocomplete for password managers
|
# Same as text, but has autocomplete for password managers
|
||||||
USERNAME = (
|
USERNAME = (
|
||||||
"username",
|
"username",
|
||||||
|
@ -80,8 +84,6 @@ class Prompt(SerializerModel):
|
||||||
kwargs = {
|
kwargs = {
|
||||||
"required": self.required,
|
"required": self.required,
|
||||||
}
|
}
|
||||||
if default:
|
|
||||||
kwargs["initial"] = default
|
|
||||||
|
|
||||||
if self.type == FieldTypes.EMAIL:
|
if self.type == FieldTypes.EMAIL:
|
||||||
field_class = EmailField
|
field_class = EmailField
|
||||||
|
@ -105,6 +107,8 @@ class Prompt(SerializerModel):
|
||||||
if self.type == FieldTypes.SEPARATOR:
|
if self.type == FieldTypes.SEPARATOR:
|
||||||
kwargs["required"] = False
|
kwargs["required"] = False
|
||||||
kwargs["label"] = ""
|
kwargs["label"] = ""
|
||||||
|
if default:
|
||||||
|
kwargs["initial"] = default
|
||||||
return field_class(**kwargs)
|
return field_class(**kwargs)
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
|
|
|
@ -97,10 +97,10 @@ class PromptChallengeResponse(ChallengeResponse):
|
||||||
# Check if we have any static or hidden fields, and ensure they
|
# Check if we have any static or hidden fields, and ensure they
|
||||||
# still have the same value
|
# still have the same value
|
||||||
static_hidden_fields: QuerySet[Prompt] = self.stage.fields.filter(
|
static_hidden_fields: QuerySet[Prompt] = self.stage.fields.filter(
|
||||||
type__in=[FieldTypes.HIDDEN, FieldTypes.STATIC]
|
type__in=[FieldTypes.HIDDEN, FieldTypes.STATIC, FieldTypes.TEXT_READ_ONLY]
|
||||||
)
|
)
|
||||||
for static_hidden in static_hidden_fields:
|
for static_hidden in static_hidden_fields:
|
||||||
attrs[static_hidden.field_key] = static_hidden.placeholder
|
attrs[static_hidden.field_key] = self.fields[static_hidden.field_key].initial
|
||||||
|
|
||||||
# Check if we have two password fields, and make sure they are the same
|
# Check if we have two password fields, and make sure they are the same
|
||||||
password_fields: QuerySet[Prompt] = self.stage.fields.filter(type=FieldTypes.PASSWORD)
|
password_fields: QuerySet[Prompt] = self.stage.fields.filter(type=FieldTypes.PASSWORD)
|
||||||
|
|
|
@ -17634,6 +17634,7 @@ paths:
|
||||||
- separator
|
- separator
|
||||||
- static
|
- static
|
||||||
- text
|
- text
|
||||||
|
- text_read_only
|
||||||
- username
|
- username
|
||||||
tags:
|
tags:
|
||||||
- stages
|
- stages
|
||||||
|
@ -28374,6 +28375,7 @@ components:
|
||||||
PromptTypeEnum:
|
PromptTypeEnum:
|
||||||
enum:
|
enum:
|
||||||
- text
|
- text
|
||||||
|
- text_read_only
|
||||||
- username
|
- username
|
||||||
- email
|
- email
|
||||||
- password
|
- password
|
||||||
|
@ -30728,4 +30730,3 @@ components:
|
||||||
servers:
|
servers:
|
||||||
- url: /api/v3/
|
- url: /api/v3/
|
||||||
- url: /api/v2beta/
|
- url: /api/v2beta/
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,13 @@ export class PromptStage extends BaseStage<PromptChallenge, PromptChallengeRespo
|
||||||
class="pf-c-form-control"
|
class="pf-c-form-control"
|
||||||
?required=${prompt.required}
|
?required=${prompt.required}
|
||||||
value="">`;
|
value="">`;
|
||||||
|
case PromptTypeEnum.TextReadOnly:
|
||||||
|
return `<input
|
||||||
|
type="text"
|
||||||
|
name="${prompt.fieldKey}"
|
||||||
|
class="pf-c-form-control"
|
||||||
|
readonly
|
||||||
|
value="${prompt.placeholder}">`;
|
||||||
case PromptTypeEnum.Username:
|
case PromptTypeEnum.Username:
|
||||||
return `<input
|
return `<input
|
||||||
type="text"
|
type="text"
|
||||||
|
|
|
@ -4723,6 +4723,10 @@ msgstr "Test Policy"
|
||||||
msgid "Test Property Mapping"
|
msgid "Test Property Mapping"
|
||||||
msgstr "Test Property Mapping"
|
msgstr "Test Property Mapping"
|
||||||
|
|
||||||
|
#: src/pages/stages/prompt/PromptForm.ts
|
||||||
|
msgid "Text (read-only): Simple Text input, but cannot be edited."
|
||||||
|
msgstr "Text (read-only): Simple Text input, but cannot be edited."
|
||||||
|
|
||||||
#: src/pages/stages/prompt/PromptForm.ts
|
#: src/pages/stages/prompt/PromptForm.ts
|
||||||
msgid "Text: Simple Text input"
|
msgid "Text: Simple Text input"
|
||||||
msgstr "Text: Simple Text input"
|
msgstr "Text: Simple Text input"
|
||||||
|
|
|
@ -4675,6 +4675,10 @@ msgstr "Tester la politique"
|
||||||
msgid "Test Property Mapping"
|
msgid "Test Property Mapping"
|
||||||
msgstr "Tester le mapping de la propriété"
|
msgstr "Tester le mapping de la propriété"
|
||||||
|
|
||||||
|
#: src/pages/stages/prompt/PromptForm.ts
|
||||||
|
msgid "Text (read-only): Simple Text input, but cannot be edited."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/stages/prompt/PromptForm.ts
|
#: src/pages/stages/prompt/PromptForm.ts
|
||||||
msgid "Text: Simple Text input"
|
msgid "Text: Simple Text input"
|
||||||
msgstr "Texte : simple champ texte"
|
msgstr "Texte : simple champ texte"
|
||||||
|
|
|
@ -4715,6 +4715,10 @@ msgstr ""
|
||||||
msgid "Test Property Mapping"
|
msgid "Test Property Mapping"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/pages/stages/prompt/PromptForm.ts
|
||||||
|
msgid "Text (read-only): Simple Text input, but cannot be edited."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/stages/prompt/PromptForm.ts
|
#: src/pages/stages/prompt/PromptForm.ts
|
||||||
msgid "Text: Simple Text input"
|
msgid "Text: Simple Text input"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
|
@ -49,6 +49,12 @@ export class PromptForm extends ModelForm<Prompt, string> {
|
||||||
>
|
>
|
||||||
${t`Text: Simple Text input`}
|
${t`Text: Simple Text input`}
|
||||||
</option>
|
</option>
|
||||||
|
<option
|
||||||
|
value=${PromptTypeEnum.TextReadOnly}
|
||||||
|
?selected=${this.instance?.type === PromptTypeEnum.TextReadOnly}
|
||||||
|
>
|
||||||
|
${t`Text (read-only): Simple Text input, but cannot be edited.`}
|
||||||
|
</option>
|
||||||
<option
|
<option
|
||||||
value=${PromptTypeEnum.Username}
|
value=${PromptTypeEnum.Username}
|
||||||
?selected=${this.instance?.type === PromptTypeEnum.Username}
|
?selected=${this.instance?.type === PromptTypeEnum.Username}
|
||||||
|
|
Reference in New Issue