Skip to content

Client.logout() also cancels any existing force_authenticate. #2218

@gaffney

Description

@gaffney

Hello

Currently logout() does not technically "log out" a user in a test if force_authenticate is enabled.

I think it would make more sense if the forced authentication was cancelled by default since I think it is more common that "logout" called from within a test would subsequently be testing unauthenticated behavior. (In our case, all tests use force_authenticate by default).

Current implementation:

def logout(self):
  self._credentials = {}
  return super(APIClient, self).logout()

Proposed implementation:

def logout(self, cancel_force_authenticate=True):
  self._credentials = {}

  if cancel_force_authenticate:
    self.handler._force_user  = None
    self.handler._force_token = None

  return super(APIClient, self).logout()

P.S. I would have made a PR for this but you might not agree with the change so I am just making an issue to suggest it.

Regards,

-- Ryan

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy