Fixes https://github.com/lesspass/lesspass/issues/699dependabot/npm_and_yarn/mobile/ansi-regex-4.1.1
@@ -0,0 +1,18 @@ | |||||
# Generated by Django 3.2.10 on 2022-02-17 20:17 | |||||
from django.db import migrations, models | |||||
class Migration(migrations.Migration): | |||||
dependencies = [ | |||||
("api", "0008_encryptedpasswordprofiles"), | |||||
] | |||||
operations = [ | |||||
migrations.AlterField( | |||||
model_name="lesspassuser", | |||||
name="key", | |||||
field=models.TextField(blank=True, default=""), | |||||
), | |||||
] |
@@ -0,0 +1,23 @@ | |||||
# Generated by Django 3.2.10 on 2022-02-17 20:17 | |||||
from django.db import migrations, models | |||||
class Migration(migrations.Migration): | |||||
dependencies = [ | |||||
("api", "0009_alter_lesspassuser_key"), | |||||
] | |||||
operations = [ | |||||
migrations.AlterField( | |||||
model_name="password", | |||||
name="login", | |||||
field=models.CharField(blank=True, default="", max_length=255), | |||||
), | |||||
migrations.AlterField( | |||||
model_name="password", | |||||
name="site", | |||||
field=models.CharField(blank=True, default="", max_length=255), | |||||
), | |||||
] |
@@ -4,23 +4,18 @@ from django.contrib.auth.models import BaseUserManager, AbstractBaseUser | |||||
class LesspassUserManager(BaseUserManager): | class LesspassUserManager(BaseUserManager): | ||||
def create_user(self, email, password=None): | |||||
def create_user(self, email, password=None, key=""): | |||||
if not email: | if not email: | ||||
raise ValueError("Users must have an email address") | raise ValueError("Users must have an email address") | ||||
user = self.model( | |||||
email=self.normalize_email(email), | |||||
) | |||||
user = self.model(email=self.normalize_email(email), key=key) | |||||
user.set_password(password) | user.set_password(password) | ||||
user.save(using=self._db) | user.save(using=self._db) | ||||
return user | return user | ||||
def create_superuser(self, email, password): | |||||
user = self.create_user( | |||||
email, | |||||
password=password, | |||||
) | |||||
def create_superuser(self, email, password, key=""): | |||||
user = self.create_user(email, password=password, key=key) | |||||
user.is_admin = True | user.is_admin = True | ||||
user.save(using=self._db) | user.save(using=self._db) | ||||
return user | return user | ||||
@@ -30,7 +25,7 @@ class LessPassUser(AbstractBaseUser): | |||||
email = models.EmailField(verbose_name="email address", max_length=255, unique=True) | email = models.EmailField(verbose_name="email address", max_length=255, unique=True) | ||||
is_active = models.BooleanField(default=True) | is_active = models.BooleanField(default=True) | ||||
is_admin = models.BooleanField(default=False) | is_admin = models.BooleanField(default=False) | ||||
key = models.TextField(null=True) | |||||
key = models.TextField(blank=True, default="") | |||||
objects = LesspassUserManager() | objects = LesspassUserManager() | ||||
@@ -77,8 +72,8 @@ class Password(DateMixin): | |||||
user = models.ForeignKey( | user = models.ForeignKey( | ||||
LessPassUser, on_delete=models.CASCADE, related_name="passwords" | LessPassUser, on_delete=models.CASCADE, related_name="passwords" | ||||
) | ) | ||||
login = models.CharField(max_length=255, null=True, blank=True) | |||||
site = models.CharField(max_length=255, null=True, blank=True) | |||||
login = models.CharField(max_length=255, blank=True, default="") | |||||
site = models.CharField(max_length=255, blank=True, default="") | |||||
lowercase = models.BooleanField(default=True) | lowercase = models.BooleanField(default=True) | ||||
uppercase = models.BooleanField(default=True) | uppercase = models.BooleanField(default=True) | ||||
@@ -13,10 +13,10 @@ class UserTestCase(APITestCase): | |||||
def test_auth_user_me(self): | def test_auth_user_me(self): | ||||
request = self.client.get("/api/auth/users/me/") | request = self.client.get("/api/auth/users/me/") | ||||
self.assertEqual(request.status_code, 200) | self.assertEqual(request.status_code, 200) | ||||
self.assertIsNone(request.data["key"]) | |||||
self.assertEqual(request.data["key"], "") | |||||
def test_update_auth_user_me(self): | def test_update_auth_user_me(self): | ||||
self.assertIsNone(models.LessPassUser.objects.first().key) | |||||
self.assertEqual(models.LessPassUser.objects.first().key, "") | |||||
request = self.client.put("/api/auth/users/me/", {"key": "abc"}) | request = self.client.put("/api/auth/users/me/", {"key": "abc"}) | ||||
self.assertEqual(request.status_code, 200) | self.assertEqual(request.status_code, 200) | ||||
self.assertEqual("abc", models.LessPassUser.objects.first().key) | self.assertEqual("abc", models.LessPassUser.objects.first().key) | ||||
@@ -192,7 +192,7 @@ if "test" in sys.argv[1:] or "jenkins" in sys.argv[1:]: | |||||
DJOSER = { | DJOSER = { | ||||
"PASSWORD_RESET_CONFIRM_URL": "#/password/reset/confirm/{uid}/{token}", | "PASSWORD_RESET_CONFIRM_URL": "#/password/reset/confirm/{uid}/{token}", | ||||
"ACTIVATION_URL": "#/activate/{uid}/{token}", | "ACTIVATION_URL": "#/activate/{uid}/{token}", | ||||
"TOKEN_MODEL": None | |||||
"TOKEN_MODEL": None, | |||||
} | } | ||||
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") | SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") | ||||
@@ -215,3 +215,8 @@ EMAIL_PORT = env.int("EMAIL_PORT", default=25) | |||||
EMAIL_SUBJECT_PREFIX = os.getenv("EMAIL_SUBJECT_PREFIX", "[LessPass] ") | EMAIL_SUBJECT_PREFIX = os.getenv("EMAIL_SUBJECT_PREFIX", "[LessPass] ") | ||||
EMAIL_USE_TLS = env.bool("EMAIL_USE_TLS", default=False) | EMAIL_USE_TLS = env.bool("EMAIL_USE_TLS", default=False) | ||||
EMAIL_USE_SSL = env.bool("EMAIL_USE_SSL", default=False) | EMAIL_USE_SSL = env.bool("EMAIL_USE_SSL", default=False) | ||||
# Default primary key field type | |||||
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field | |||||
DEFAULT_AUTO_FIELD = "django.db.models.AutoField" |