def logout_then_login(request,
                      login_url=reverse_lazy('login'),
                      current_app=None,
                      extra_context=None):
    """
    Logout then login
    """
    permissions.revoke_user_course_permissions(request.user)
    return django.contrib.auth.views.logout_then_login(request, login_url,
                                                       current_app,
                                                       extra_context)
Esempio n. 2
0
def logout(request, next_page='/', template_name=None,
           redirect_field_name=REDIRECT_FIELD_NAME, current_app=None, extra_context=None):
    """
    Revoke user permissions and logout
    """

    # Revoke permissions
    permissions.revoke_user_course_permissions(request.user)

    # Back to the standard logout flow
    return django.contrib.auth.views.logout(request, next_page, template_name, redirect_field_name, current_app,
                                            extra_context)
    def test_revoke_user_permissions(self):
        courses = [self.course_id]
        permissions_key = 'course_permissions_{}'.format(self.user.pk)
        update_key = 'course_permissions_updated_at_{}'.format(self.user.pk)

        # Set permissions and verify cache is updated
        permissions.set_user_course_permissions(self.user, courses)
        self.assertListEqual(cache.get(permissions_key), courses)
        self.assertIsNotNone(cache.get(update_key))
        self.assertTrue(permissions.user_can_view_course(self.user, self.course_id))

        # Revoke permissions and verify cache cleared
        permissions.revoke_user_course_permissions(self.user)
        self.assertIsNone(cache.get(permissions_key))
        self.assertIsNone(cache.get(update_key))
Esempio n. 4
0
    def test_revoke_user_permissions(self):
        courses = [self.course_id]
        permissions_key = 'course_permissions_{}'.format(self.user.pk)
        update_key = 'course_permissions_updated_at_{}'.format(self.user.pk)

        # Set permissions and verify cache is updated
        permissions.set_user_course_permissions(self.user, courses)
        self.assertListEqual(cache.get(permissions_key), courses)
        self.assertIsNotNone(cache.get(update_key))
        self.assertTrue(permissions.user_can_view_course(self.user, self.course_id))

        # Revoke permissions and verify cache cleared
        permissions.revoke_user_course_permissions(self.user)
        self.assertIsNone(cache.get(permissions_key))
        self.assertIsNone(cache.get(update_key))
Esempio n. 5
0
 def revoke_permissions(self, user):
     revoke_user_course_permissions(user)
 def revoke_permissions(self, user):
     revoke_user_course_permissions(user)
def logout_then_login(request, login_url=reverse_lazy('login'), current_app=None, extra_context=None):
    """
    Logout then login
    """
    permissions.revoke_user_course_permissions(request.user)
    return django.contrib.auth.views.logout_then_login(request, login_url, current_app, extra_context)