def GetUserInfo(http_cookie, cookie_name=COOKIE_NAME):
 COOKIE_SECRET = ''
 try:
  COOKIE_SECRET = os.environ['COOKIE_SECRET']
 except Exception as e:
  logging.info(('WARNING: Cookie secret not set' + str(e)))
 cookie = Cookie.SimpleCookie(http_cookie)
 valid_cookie = True
 cookie_value = ''
 if (cookie_name in cookie):
  cookie_value = cookie[cookie_name].value
 cookie_value = cookie_value.replace('%3A', ':')
 cookie_value = cookie_value.replace('%40', '@')
 cookie_value = cookie_value.replace('%2C', ',')
 (email, nickname, admin, hsh) = (cookie_value.split(':') + ['', '', '', ''])[:4]
 if (email == ''):
  nickname = ''
  admin = ''
  return ('', '', False, False)
 else:
  vhsh = sha.new((((email + nickname) + admin) + COOKIE_SECRET)).hexdigest()
  if (hsh != vhsh):
   logging.info((email + ' had invalid cookie, clearing it'))
   valid_cookie = False
   email = ''
   admin = ''
   nickname = ''
   return ('', '', False, False)
 isAdmin = False
 admin_apps = admin.split(',')
 current_app = os.environ['APPLICATION_ID']
 if (current_app in admin_apps):
  isAdmin = True
 return (email, nickname, isAdmin, valid_cookie)

def GetUserInfo ( http_cookie , cookie_name = COOKIE_NAME ) : COOKIE_SECRET = '' try : COOKIE_SECRET = os . environ [ 'COOKIE_SECRET' ] except Exception as e : logging . info ( ( 'WARNING: Cookie secret not set' + str ( e ) ) ) cookie = Cookie . SimpleCookie ( http_cookie ) valid_cookie = True cookie_value = '' if ( cookie_name in cookie ) : cookie_value = cookie [ cookie_name ] . value cookie_value = cookie_value . replace ( '%3A' , ':' ) cookie_value = cookie_value . replace ( '%40' , '@' ) cookie_value = cookie_value . replace ( '%2C' , ',' ) ( email , nickname , admin , hsh ) = ( cookie_value . split ( ':' ) + [ '' , '' , '' , '' ] ) [ : 4 ] if ( email == '' ) : nickname = '' admin = '' return ( '' , '' , False , False ) else : vhsh = sha . new ( ( ( ( email + nickname ) + admin ) + COOKIE_SECRET ) ) . hexdigest ( ) if ( hsh != vhsh ) : logging . info ( ( email + ' had invalid cookie, clearing it' ) ) valid_cookie = False email = '' admin = '' nickname = '' return ( '' , '' , False , False ) isAdmin = False admin_apps = admin . split ( ',' ) current_app = os . environ [ 'APPLICATION_ID' ] if ( current_app in admin_apps ) : isAdmin = True return ( email , nickname , isAdmin , valid_cookie )
get a user protobuf for a specific user .