diff --git a/passbook/stages/user_login/migrations/0003_session_duration_delta.py b/passbook/stages/user_login/migrations/0003_session_duration_delta.py index 5d0c0d8d9..265cfbeaa 100644 --- a/passbook/stages/user_login/migrations/0003_session_duration_delta.py +++ b/passbook/stages/user_login/migrations/0003_session_duration_delta.py @@ -14,10 +14,7 @@ def update_duration(apps: Apps, schema_editor: BaseDatabaseSchemaEditor): for stage in UserLoginStage.objects.using(db_alias).all(): if stage.session_duration.isdigit(): - if stage.session_duration == 0: - stage.session_duration = "seconds=1" - else: - stage.session_duration = f"seconds={stage.session_duration}" + stage.session_duration = f"seconds={stage.session_duration}" stage.save() @@ -32,8 +29,8 @@ class Migration(migrations.Migration): model_name="userloginstage", name="session_duration", field=models.TextField( - default="seconds=-1", - help_text="Determines how long a session lasts. Default of -1 means that the sessions lasts until the browser is closed. (Format: hours=-1;minutes=-2;seconds=-3)", + default="seconds=0", + help_text="Determines how long a session lasts. Default of 0 means that the sessions lasts until the browser is closed. (Format: hours=-1;minutes=-2;seconds=-3)", validators=[passbook.lib.utils.time.timedelta_string_validator], ), ), diff --git a/passbook/stages/user_login/models.py b/passbook/stages/user_login/models.py index 690de176e..d70be4a87 100644 --- a/passbook/stages/user_login/models.py +++ b/passbook/stages/user_login/models.py @@ -15,10 +15,10 @@ class UserLoginStage(Stage): """Attaches the currently pending user to the current session.""" session_duration = models.TextField( - default="seconds=-1", + default="seconds=0", validators=[timedelta_string_validator], help_text=_( - "Determines how long a session lasts. Default of -1 means " + "Determines how long a session lasts. Default of 0 means " "that the sessions lasts until the browser is closed. " "(Format: hours=-1;minutes=-2;seconds=-3)" ), diff --git a/passbook/stages/user_login/stage.py b/passbook/stages/user_login/stage.py index dc3619007..f2bd4c05c 100644 --- a/passbook/stages/user_login/stage.py +++ b/passbook/stages/user_login/stage.py @@ -2,7 +2,6 @@ from django.contrib import messages from django.contrib.auth import login from django.http import HttpRequest, HttpResponse -from django.utils.timezone import now from django.utils.translation import gettext as _ from structlog import get_logger @@ -35,11 +34,10 @@ class UserLoginStageView(StageView): backend=backend, ) delta = timedelta_from_string(self.executor.current_stage.session_duration) - if delta.seconds == -1: + if delta.seconds == 0: self.request.session.set_expiry(0) else: - expiry = now() + delta - self.request.session.set_expiry(expiry) + self.request.session.set_expiry(delta) LOGGER.debug( "Logged in", user=self.executor.plan.context[PLAN_CONTEXT_PENDING_USER],