From 2d3de77bf61ec6e0571006a893f956196d2b3e5b Mon Sep 17 00:00:00 2001 From: Chase Sterling Date: Wed, 13 Jul 2016 22:47:24 -0400 Subject: [PATCH] Use github's anonymous email standin when github auth user has email as private --- realms/modules/auth/oauth/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/realms/modules/auth/oauth/models.py b/realms/modules/auth/oauth/models.py index 72f0470..d7f7680 100644 --- a/realms/modules/auth/oauth/models.py +++ b/realms/modules/auth/oauth/models.py @@ -40,7 +40,7 @@ providers = { 'field_map': { 'id': 'id', 'username': 'login', - 'email': 'email' + 'email': lambda(data): data.get('email') or data['login'] + '@users.noreply.github.com' }, 'token_name': 'access_token' }, @@ -118,6 +118,8 @@ class User(BaseUser): def get_value(d, key): if isinstance(key, basestring): return d.get(key) + elif callable(key): + return key(d) # key should be list here val = d.get(key.pop(0)) if len(key) == 0: