From feba3e24302ac5e3419542b2b29cdd06e927405e Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 15 Jun 2020 19:05:18 +0200 Subject: [PATCH] stages/prompt: Add username type field add autocomplete attributes for username and password --- .../migrations/0003_auto_20200615_1641.py | 28 ++++++++++++++++ .../migrations/0003_auto_20200615_1641.py | 33 +++++++++++++++++++ passbook/stages/prompt/models.py | 10 ++++++ swagger.yaml | 1 + 4 files changed, 72 insertions(+) create mode 100644 passbook/stages/identification/migrations/0003_auto_20200615_1641.py create mode 100644 passbook/stages/prompt/migrations/0003_auto_20200615_1641.py diff --git a/passbook/stages/identification/migrations/0003_auto_20200615_1641.py b/passbook/stages/identification/migrations/0003_auto_20200615_1641.py new file mode 100644 index 000000000..a6451a360 --- /dev/null +++ b/passbook/stages/identification/migrations/0003_auto_20200615_1641.py @@ -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", + ), + ), + ] diff --git a/passbook/stages/prompt/migrations/0003_auto_20200615_1641.py b/passbook/stages/prompt/migrations/0003_auto_20200615_1641.py new file mode 100644 index 000000000..6ba175cc7 --- /dev/null +++ b/passbook/stages/prompt/migrations/0003_auto_20200615_1641.py @@ -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, + ), + ), + ] diff --git a/passbook/stages/prompt/models.py b/passbook/stages/prompt/models.py index fc12c7b2e..616330d54 100644 --- a/passbook/stages/prompt/models.py +++ b/passbook/stages/prompt/models.py @@ -12,7 +12,10 @@ from passbook.policies.models import PolicyBindingModel class FieldTypes(models.TextChoices): """Field types an Prompt can be""" + # Simple text field TEXT = "text" + # Same as text, but has autocomplete for password managers + USERNAME = "username" EMAIL = "e-mail" PASSWORD = "password" # noqa # nosec NUMBER = "number" @@ -52,8 +55,11 @@ class Prompt(models.Model): } if self.type == FieldTypes.EMAIL: field_class = forms.EmailField + if self.type == FieldTypes.USERNAME: + attrs["autocomplete"] = "username" if self.type == FieldTypes.PASSWORD: widget = forms.PasswordInput(attrs=attrs) + attrs["autocomplete"] = "new-password" if self.type == FieldTypes.NUMBER: field_class = forms.IntegerField widget = forms.NumberInput(attrs=attrs) @@ -64,6 +70,10 @@ class Prompt(models.Model): if self.type == FieldTypes.CHECKBOX: field_class = forms.CheckboxInput 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 separator diff --git a/swagger.yaml b/swagger.yaml index bfbe87493..9c326a331 100755 --- a/swagger.yaml +++ b/swagger.yaml @@ -6079,6 +6079,7 @@ definitions: type: string enum: - text + - username - e-mail - password - number