Esempio n. 1
0
    def login_2fa(self, user):
        session = self.client.session

        user_manager = UserAuthenticationManager(session)
        user_manager.set_user(user)

        session.save()
        return True
    def test_set_or_get_or_unset_user(self):
        manager = UserAuthenticationManager(self.session)
        self.assertEqual(manager.get_user(), AnonymousUser())

        manager.set_user(self.user)
        self.assertEqual(manager.get_user(), self.user)
        self.assertEqual(manager.get_identified_user(), self.user)

        manager.unset_user()
        self.assertEqual(manager.get_user(), AnonymousUser())
        self.assertEqual(manager.get_identified_user(), None)
Esempio n. 3
0
 def login_2fa_factory(self, request, user):
     session = getattr(request, 'session', {})
     user_manager = UserAuthenticationManager(session)
     user_manager.set_user(user)
     request.session = session