<commit_before>from django.shortcuts import redirect
from django.contrib.auth.decorators import login_required
import SECURE_CONFIG
from django.core.urlresolvers import reverse
from django.http import HttpResponse
import oauth2
import json
from .models import *
import urllib, urllib2
from django.conf import settings

@login_required
def requestAttributes(request):
	url = settings.IDP_AUTHORIZATION_URL
	url += "redirect_uri="+settings.IDP_MY_REDIRECT
	url += "&client_id="+SECURE_CONFIG.IDP_CLIENT_ID
	url += "&response_type=code"
	try:
		url += "&scope="+','.join([s.scope for s in Scope.objects.filter(type=Type.objects.get(type='identity'))])
	except Type.DoesNotExist: return redirect('home')
	state = oauth2.generateState(request.user)
	url += '&state='+state
	return redirect(url)
	#return HttpResponse(url)

@login_required
def attributesRedirect(request):
	token = oauth2.exchangeCodeForToken(request, SECURE_CONFIG.IDP_CLIENT_ID, SECURE_CONFIG.IDP_CLIENT_SECRET, settings.IDP_MY_REDIRECT, settings.IDP_URL+'oauth2/oauth2/token/?')
	if 'error' in token:
		return HttpResponse(token)
		return redirect('home')
	oauth2.saveToken(request.user, token)
	getAttributes(request.user, ['first_name'])
	return redirect('home')

@login_required
def test(request):
	return HttpResponse(getAttributes(request.user, ['email']))
<commit_msg>fixed case when user clicks no to identity prompt<commit_after>from django.shortcuts import redirect
from django.contrib.auth.decorators import login_required
import SECURE_CONFIG
from django.core.urlresolvers import reverse
from django.http import HttpResponse
import oauth2
import json
from .models import *
import urllib, urllib2
from django.conf import settings

@login_required
def requestAttributes(request):
	url = settings.IDP_AUTHORIZATION_URL
	url += "redirect_uri="+settings.IDP_MY_REDIRECT
	url += "&client_id="+SECURE_CONFIG.IDP_CLIENT_ID
	url += "&response_type=code"
	try:
		url += "&scope="+','.join([s.scope for s in Scope.objects.filter(type=Type.objects.get(type='identity'))])
	except Type.DoesNotExist: return redirect('home')
	state = oauth2.generateState(request.user)
	url += '&state='+state
	return redirect(url)
	#return HttpResponse(url)

@login_required
def attributesRedirect(request):
	token = oauth2.exchangeCodeForToken(request, SECURE_CONFIG.IDP_CLIENT_ID, SECURE_CONFIG.IDP_CLIENT_SECRET, settings.IDP_MY_REDIRECT, settings.IDP_URL+'oauth2/oauth2/token/?')
	if 'error' in token:
		return redirect('home')
	oauth2.saveToken(request.user, token)
	getAttributes(request.user, ['first_name'])
	return redirect('home')

@login_required
def test(request):
	return HttpResponse(getAttributes(request.user, ['email']))

{'fraction_non_alphanumeric': 0.11554230339172568, 'fraction_numerical': 0.005218039508013418, 'mean_word_length': 7.361370716510903, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3247045', 'n_tokens_mistral': 881, 'n_tokens_neox': 886, 'n_words': 188}