Commit 21d51acf authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB

Make ligoauth.context_processors more robust

parent 1b76f46e
......@@ -5,10 +5,12 @@ from .utils import is_internal
def LigoAuthContext(request):
user = None
user_is_internal = False
user_is_lvem = False
user_is_advocate = False # user is an EM advocate
if request.user:
if hasattr(request, 'user'):
user = request.user
if is_internal(request.user):
user_is_internal = True
if request.user.groups.filter(name=settings.LVEM_GROUP).exists():
......@@ -16,5 +18,5 @@ def LigoAuthContext(request):
if request.user.groups.filter(name=settings.EM_ADVOCATE_GROUP).exists():
user_is_advocate = True
return {'user': request.user, 'user_is_internal': user_is_internal,
return {'user': user, 'user_is_internal': user_is_internal,
'user_is_lvem': user_is_lvem, 'user_is_advocate': user_is_advocate}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment