MCPcopy
hub / github.com/django/django / groups_for_user

Function groups_for_user

django/contrib/auth/handlers/modwsgi.py:44–58  ·  view source on GitHub ↗

Authorize a user based on groups

(environ, username)

Source from the content-addressed store, hash-verified

42
43
44def groups_for_user(environ, username):
45 """
46 Authorize a user based on groups
47 """
48 db.reset_queries()
49 try:
50 try:
51 user = UserModel._default_manager.get_by_natural_key(username)
52 except UserModel.DoesNotExist:
53 return []
54 if not user.is_active:
55 return []
56 return [group.name.encode() for group in user.groups.all()]
57 finally:
58 db.close_old_connections()

Callers 1

test_groups_for_userMethod · 0.90

Calls 3

get_by_natural_keyMethod · 0.45
encodeMethod · 0.45
allMethod · 0.45

Tested by 1

test_groups_for_userMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…