Skip to content

Commit

Permalink
fix: token generation
Browse files Browse the repository at this point in the history
  • Loading branch information
mjaquiery committed Jun 25, 2024
1 parent f80a34c commit 4edb009
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 12 deletions.
2 changes: 1 addition & 1 deletion backend_django/config/settings_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Build paths inside the project like this: BASE_DIR / 'subdir'.
import os

API_VERSION = "2.1.45"
API_VERSION = "2.1.46"

try:
USER_ACTIVATION_TOKEN_EXPIRY_S = int(os.environ.get("DJANGO_USER_ACTIVATION_TOKEN_EXPIRY_S"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0.3 on 2024-06-25 06:58

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('galv', '0042_alter_schemavalidation_schema'),
]

operations = [
migrations.AlterField(
model_name='datacolumntype',
name='data_type',
field=models.TextField(choices=[('int', 'int'), ('float', 'float'), ('str', 'str'), ('bool', 'bool'), ('datetime64[ns]', 'datetime64[ns]')], default='float', help_text='Type of the data in this column.'),
),
]
2 changes: 1 addition & 1 deletion backend_django/galv/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1616,7 +1616,7 @@ class DataColumnType(ResourceModelPermissionsMixin, ValidatableBySchemaMixin):
data_type = models.TextField(
null=False,
choices=[(v, v) for v in DATA_TYPES],
help_text="Type of the data in this column",
help_text="Type of the data in this column.",
default="float"
)
is_default = models.BooleanField(
Expand Down
6 changes: 3 additions & 3 deletions backend_django/galv/serializers/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,19 +641,19 @@ class WithTeamMixin(serializers.Serializer):
choices=[(v.value, v.label) for v in ALLOWED_USER_LEVELS_READ],
help_text="Minimum user level required to read this resource",
allow_null=True,
required=False
default=UserLevel.LAB_MEMBER.value
)
edit_access_level = serializers.ChoiceField(
choices=[(v.value, v.label) for v in ALLOWED_USER_LEVELS_EDIT],
help_text="Minimum user level required to edit this resource",
allow_null=True,
required=False
default=UserLevel.TEAM_MEMBER.value
)
delete_access_level = serializers.ChoiceField(
choices=[(v.value, v.label) for v in ALLOWED_USER_LEVELS_DELETE],
help_text="Minimum user level required to create this resource",
allow_null=True,
required=False
default=UserLevel.TEAM_MEMBER.value
)

def validate_team(self, value):
Expand Down
10 changes: 5 additions & 5 deletions backend_django/galv/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,14 +460,14 @@ def get_token_ttl(self):

def get_post_response_data(self, request, token, instance):
# clean up expired user tokens
for token in KnoxAuthToken.objects.filter(user=request.user):
for t in KnoxAuthToken.objects.filter(user=request.user):
try:
knox_token = AuthToken.objects.get(token_key=token.knox_token_key)
knox_token = AuthToken.objects.get(token_key=t.knox_token_key)
except AuthToken.DoesNotExist:
token.delete()
t.delete()
continue
if knox_token.expiry < timezone.now():
token.delete()
if knox_token.expiry is not None and knox_token.expiry < timezone.now():
t.delete()

error = None
name = request.data.get('name')
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
project = 'Galv'
copyright = '2023, Oxford RSE'
author = 'Oxford RSE'
release = '2.1.45'
release = '2.1.46'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion docs/tags.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["v2.1.45","main"]
["v2.1.46","main"]

0 comments on commit 4edb009

Please sign in to comment.