def test_is_google_authenticated(self, mock_social_auth_key): user = User.objects.get(username='******') r = is_google_authenticated(user) self.assertTrue(r) local_user = User.objects.get(username='******') r = is_google_authenticated(local_user) self.assertFalse(r) mock_social_auth_key.__bool__.return_value = False r = is_google_authenticated(user) self.assertFalse(r)
def get_all_users(request): user_tups = [(user, _get_json_for_user(user, is_anvil=False)) for user in User.objects.exclude(email='')] users = [ dict(hasGoogleAuth=is_google_authenticated(user), **user_json) for user, user_json in user_tups ] return create_json_response({'users': users})
def _validate_airtable_access(user): if not (is_google_authenticated(user) and user.email.endswith('broadinstitute.org')): raise PermissionDenied('Error: To access airtable user must login with Google authentication.')