stop putting invite user objects in the session

the invited_user objects can be arbitrarily large, and when we put them
in the session we risk going over the session cookie's 4kb size limit.
since https://github.com/alphagov/notifications-admin/pull/3827 was
merged, we store the user id in the session. Now that's been live for a
day or two we can safely stop putting the rich object in the session.

Needed to change a bunch of tests for this to make sure appropriate
mocks were set. Also some tests were accidentally re-using fake_uuid.

Still pop the object when cleaning up sessions. We'll need to remove
that in a future PR.
This commit is contained in:
Leo Hemsted
2021-03-16 17:58:27 +00:00
parent 1a63c2c8be
commit 8a2fec6f18
8 changed files with 68 additions and 167 deletions

View File

@@ -522,11 +522,7 @@ class InvitedUser(JSONModel):
@classmethod
def from_session(cls):
invited_user_id = session.get('invited_user_id')
if invited_user_id:
return cls.by_id(invited_user_id)
invited_user = session.get('invited_user')
return cls(invited_user) if invited_user else None
return cls.by_id(invited_user_id) if invited_user_id else None
def has_permissions(self, *permissions):
if self.status == 'cancelled':
@@ -606,11 +602,7 @@ class InvitedOrgUser(JSONModel):
@classmethod
def from_session(cls):
invited_org_user_id = session.get('invited_org_user_id')
if invited_org_user_id:
return cls.by_id(invited_org_user_id)
invited_org_user = session.get('invited_org_user')
return cls(invited_org_user) if invited_org_user else None
return cls.by_id(invited_org_user_id) if invited_org_user_id else None
@classmethod
def by_id_and_org_id(cls, org_id, invited_user_id):