stages/prompt: Add username type field
add autocomplete attributes for username and password
This commit is contained in:
parent
b49d39a685
commit
feba3e2430
|
@ -0,0 +1,28 @@
|
||||||
|
# Generated by Django 3.0.7 on 2020-06-15 16:41
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("passbook_flows", "0005_provider_flows"),
|
||||||
|
("passbook_stages_identification", "0002_auto_20200530_2204"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="identificationstage",
|
||||||
|
name="recovery_flow",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
blank=True,
|
||||||
|
default=None,
|
||||||
|
help_text="Optional recovery flow, which is linked at the bottom of the page.",
|
||||||
|
null=True,
|
||||||
|
on_delete=django.db.models.deletion.SET_DEFAULT,
|
||||||
|
related_name="+",
|
||||||
|
to="passbook_flows.Flow",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,33 @@
|
||||||
|
# Generated by Django 3.0.7 on 2020-06-15 16:41
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("passbook_stages_prompt", "0002_auto_20200528_2059"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="prompt",
|
||||||
|
name="type",
|
||||||
|
field=models.CharField(
|
||||||
|
choices=[
|
||||||
|
("text", "Text"),
|
||||||
|
("username", "Username"),
|
||||||
|
("e-mail", "Email"),
|
||||||
|
("password", "Password"),
|
||||||
|
("number", "Number"),
|
||||||
|
("checkbox", "Checkbox"),
|
||||||
|
("data", "Date"),
|
||||||
|
("data-time", "Date Time"),
|
||||||
|
("separator", "Separator"),
|
||||||
|
("hidden", "Hidden"),
|
||||||
|
("static", "Static"),
|
||||||
|
],
|
||||||
|
max_length=100,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -12,7 +12,10 @@ from passbook.policies.models import PolicyBindingModel
|
||||||
class FieldTypes(models.TextChoices):
|
class FieldTypes(models.TextChoices):
|
||||||
"""Field types an Prompt can be"""
|
"""Field types an Prompt can be"""
|
||||||
|
|
||||||
|
# Simple text field
|
||||||
TEXT = "text"
|
TEXT = "text"
|
||||||
|
# Same as text, but has autocomplete for password managers
|
||||||
|
USERNAME = "username"
|
||||||
EMAIL = "e-mail"
|
EMAIL = "e-mail"
|
||||||
PASSWORD = "password" # noqa # nosec
|
PASSWORD = "password" # noqa # nosec
|
||||||
NUMBER = "number"
|
NUMBER = "number"
|
||||||
|
@ -52,8 +55,11 @@ class Prompt(models.Model):
|
||||||
}
|
}
|
||||||
if self.type == FieldTypes.EMAIL:
|
if self.type == FieldTypes.EMAIL:
|
||||||
field_class = forms.EmailField
|
field_class = forms.EmailField
|
||||||
|
if self.type == FieldTypes.USERNAME:
|
||||||
|
attrs["autocomplete"] = "username"
|
||||||
if self.type == FieldTypes.PASSWORD:
|
if self.type == FieldTypes.PASSWORD:
|
||||||
widget = forms.PasswordInput(attrs=attrs)
|
widget = forms.PasswordInput(attrs=attrs)
|
||||||
|
attrs["autocomplete"] = "new-password"
|
||||||
if self.type == FieldTypes.NUMBER:
|
if self.type == FieldTypes.NUMBER:
|
||||||
field_class = forms.IntegerField
|
field_class = forms.IntegerField
|
||||||
widget = forms.NumberInput(attrs=attrs)
|
widget = forms.NumberInput(attrs=attrs)
|
||||||
|
@ -64,6 +70,10 @@ class Prompt(models.Model):
|
||||||
if self.type == FieldTypes.CHECKBOX:
|
if self.type == FieldTypes.CHECKBOX:
|
||||||
field_class = forms.CheckboxInput
|
field_class = forms.CheckboxInput
|
||||||
kwargs["required"] = False
|
kwargs["required"] = False
|
||||||
|
if self.type == FieldTypes.DATE:
|
||||||
|
field_class = forms.DateInput
|
||||||
|
if self.type == FieldTypes.DATE_TIME:
|
||||||
|
field_class = forms.DateTimeInput
|
||||||
|
|
||||||
# TODO: Implement static
|
# TODO: Implement static
|
||||||
# TODO: Implement separator
|
# TODO: Implement separator
|
||||||
|
|
|
@ -6079,6 +6079,7 @@ definitions:
|
||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
- text
|
- text
|
||||||
|
- username
|
||||||
- e-mail
|
- e-mail
|
||||||
- password
|
- password
|
||||||
- number
|
- number
|
||||||
|
|
Reference in New Issue