def create_profile(self, http_request): email = '*****@*****.**' http_request.return_value = FakeResponse( 200, {'status': 'okay', 'email': email}) request = fake_request() browserid_authenticate(request=request, assertion='fake-assertion') return UserProfile.objects.get(email=email)
def create_profile(self, http_request): email = '*****@*****.**' http_request.return_value = FakeResponse(200, { 'status': 'okay', 'email': email }) request = fake_request() browserid_authenticate(request=request, assertion='fake-assertion') return UserProfile.objects.get(email=email)
def create_action(self, request, serializer): with statsd.timer('auth.browserid.verify'): profile, msg = browserid_authenticate( request, serializer.data['assertion'], browserid_audience=serializer.data['audience'] or get_audience(request), is_mobile=serializer.data['is_mobile'], ) if profile is None: # Authentication failure. log.info('No profile: %s' % (msg or '')) raise AuthenticationFailed('No profile.') request.user = profile request.groups = profile.groups.all() auth.login(request, profile) profile.log_login_attempt(True) # TODO: move this to the signal. user_logged_in.send(sender=profile.__class__, request=request, user=profile) # We want to return completely custom data, not the serializer's. data = { 'error': None, 'token': commonplace_token(request.user.email), 'settings': { 'display_name': request.user.display_name, 'email': request.user.email, 'enable_recommendations': request.user.enable_recommendations, } } # Serializers give up if they aren't passed an instance, so we # do that here despite PermissionsSerializer not needing one # really. permissions = PermissionsSerializer(context={'request': request}, instance=True) data.update(permissions.data) # Add ids of installed/purchased/developed apps. data['apps'] = user_relevant_apps(profile) return data