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)
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)
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)
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))
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)
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)
def revoke_permissions(self, user): revoke_user_course_permissions(user)