<commit_before>from flask import request, session, redirect, url_for, jsonify
from models import connection
from urllib2 import Request, urlopen, URLError
from hashlib import sha512
from base64 import b64encode
import urllib, urlparse, hmac
from providers import *
import json, config
from helpers import crossdomain, plain_resp
from interfaces import ItsdangerousSessionInterface
from os import environ

from hummedia import app
#app.session_interface = ItsdangerousSessionInterface()
app.secret_key=config.SECRET_KEY
provider_lookup={"google":GoogleOAuth2,"cas":CasAuth}
oAuthService = provider_lookup["google"]("google") # done this way so eventually we can have multiple providers ... for now, it's hard coded
cas = provider_lookup["cas"]()
provider = oAuthService.get_remote_app()

@provider.tokengetter
def get_access_token():
    return session.get('access_token')
    
def get_user():
    return session.get('username')
    
def get_role():
    return session.get('role')
    
def superuser():
    return session.get('superuser')
    
def get_profile():
    atts={}
    for att in ['username','role','superuser','fullname','preferredLanguage']:
        atts[att]=session.get(att)
    if (atts['username'] is None or atts['username']=="") and session.get('oauth'):
	atts['oauth']=session.get('oauth')['provider']
    return atts
    
def get_redirect_url():
    r = session.get("redirect") if session.get("redirect") else url_for("profile")
    params={"username":get_user()} if get_user() else {}
    url_parts = list(urlparse.urlparse(r))
    query = urlparse.parse_qs(url_parts[4])
    query.update(params)
    url_parts[4] = urllib.urlencode(query)
    return urlparse.urlunparse(url_parts)
  
def set_session_vars(user):
    for att in ('username','role','superuser','fullname','preferredLanguage'):
        if att in user:
            session[att]=user[att]
<commit_msg>removed appendage of username to valid login redirect url<commit_after>from flask import request, session, redirect, url_for, jsonify
from models import connection
from urllib2 import Request, urlopen, URLError
from hashlib import sha512
from base64 import b64encode
import urllib, urlparse, hmac
from providers import *
import json, config
from helpers import crossdomain, plain_resp
from interfaces import ItsdangerousSessionInterface
from os import environ

from hummedia import app
#app.session_interface = ItsdangerousSessionInterface()
app.secret_key=config.SECRET_KEY
provider_lookup={"google":GoogleOAuth2,"cas":CasAuth}
oAuthService = provider_lookup["google"]("google") # done this way so eventually we can have multiple providers ... for now, it's hard coded
cas = provider_lookup["cas"]()
provider = oAuthService.get_remote_app()

@provider.tokengetter
def get_access_token():
    return session.get('access_token')
    
def get_user():
    return session.get('username')
    
def get_role():
    return session.get('role')
    
def superuser():
    return session.get('superuser')
    
def get_profile():
    atts={}
    for att in ['username','role','superuser','fullname','preferredLanguage']:
        atts[att]=session.get(att)
    if (atts['username'] is None or atts['username']=="") and session.get('oauth'):
	atts['oauth']=session.get('oauth')['provider']
    return atts
    
def get_redirect_url():
    r = session.get("redirect") if session.get("redirect") else url_for("profile")
    url_parts = list(urlparse.urlparse(r))
    query = urlparse.parse_qs(url_parts[4])
    url_parts[4] = urllib.urlencode(query)
    return urlparse.urlunparse(url_parts)
  
def set_session_vars(user):
    for att in ('username','role','superuser','fullname','preferredLanguage'):
        if att in user:
            session[att]=user[att]

{'fraction_non_alphanumeric': 0.12204935622317596, 'fraction_numerical': 0.005901287553648069, 'mean_word_length': 5.215, 'pattern_counts': {'":': 5, '<': 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': '5127152', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1115, 'n_words': 295}