Example #1
0
    def dispatch(self, request, *args, **kwargs):
        """
        Revoke user permissions and logout
        """
        # Revoke permissions
        permissions.revoke_user_course_permissions(request.user)

        # Back to the standard logout flow
        return super().dispatch(request, *args, **kwargs)
Example #2
0
    def dispatch(self, request, *args, **kwargs):
        """
        Revoke user permissions and logout
        """
        # Revoke permissions
        permissions.revoke_user_course_permissions(request.user)

        # Back to the standard logout flow
        return super(InsightsLogoutView, self).dispatch(request, *args, **kwargs)
Example #3
0
def logout_then_login(request,
                      login_url=reverse_lazy('login'),
                      extra_context=None):
    """
    Logout then login
    """
    permissions.revoke_user_course_permissions(request.user)
    return django.contrib.auth.views.logout_then_login(request, login_url,
                                                       extra_context)
Example #4
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)
Example #5
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))
Example #6
0
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)
Example #7
0
def insights_logout_then_login(request, login_url=reverse_lazy('login')):
    """
    Logout then login
    """
    permissions.revoke_user_course_permissions(request.user)
    return logout_then_login(request, login_url=login_url)
Example #8
0
def insights_logout_then_login(request, login_url=reverse_lazy('login')):
    """
    Logout then login
    """
    permissions.revoke_user_course_permissions(request.user)
    return logout_then_login(request, login_url=login_url)
Example #9
0
 def revoke_permissions(self, user):
     revoke_user_course_permissions(user)