User session tracking #93587
@ -689,5 +689,4 @@ class UserSession(models.Model):
|
||||
def device(self):
|
||||
if self.user_agent:
|
||||
return user_agents.parse(self.user_agent)
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
Oleg-Komarov marked this conversation as resolved
Outdated
|
||||
|
@ -448,7 +448,8 @@ class ActiveSessionsView(LoginRequiredMixin, TemplateView):
|
||||
|
||||
class TerminateSessionView(LoginRequiredMixin, View):
|
||||
def post(self, request, *args, **kwargs):
|
||||
if user_session := self.request.user.sessions.filter(pk=kwargs.get('pk', 0)).first():
|
||||
user_session_pk = kwargs.get('pk')
|
||||
Oleg-Komarov marked this conversation as resolved
Outdated
Anna Sirota
commented
getting the getting the `pk` (`pk = kwargs['pk']`: it's fine to expect it to be present at this point) and filtering the session on the separate line would make this more readable.
|
||||
if user_session := self.request.user.sessions.filter(pk=user_session_pk).first():
|
||||
user_session.session.delete()
|
||||
user_session.delete()
|
||||
return redirect('bid_main:active_sessions')
|
||||
|
Loading…
Reference in New Issue
Block a user
superfluous else