Пример #1
0
def supplant(request):
    """Change password for user to allow access to administrator"""
    
    import cx_Oracle;
    con = servicios.conexOracle(cx_Oracle)
    cur = con.cursor()
    supplantUser = request.session['supplantUser']
    
    #Check if already there is a user suplanted
    res = cur.execute("select email from qcdata.users where user_name='fija.suplantar.es'")
    email = res.fetchall()[0][0]
    if email:
        error = "There is already an user supplanted. Please, use first 'End supplant'"
        return render_to_response('workflowCodeManager/error.html', {'error': error}, context_instance=RequestContext(request))
    
    #Obtain current user password
    res = cur.execute("select user_password from qcdata.users where user_name='" + supplantUser + "'")
    userPassword = res.fetchall()[0][0]
    
    #Store use password in user fija.suplantar.es
    cur.execute("update qcdata.users set USER_PASSWORD='******', email='" + supplantUser + "' where user_name='fija.suplantar.es'")
    
    #Change user password with our password
    supplantPassword = "******"
    cur.execute("update qcdata.users set USER_PASSWORD='******' where user_name='" + supplantUser + "'")
    cur.execute("commit")
    con.close()
    
    return render_to_response('workflowCodeManager/fija/supplant.html', {'active': True, 'user': supplantUser}, context_instance=RequestContext(request))
Пример #2
0
def end_supplant(request):
    """Change back password for user"""

    import cx_Oracle;
    con = servicios.conexOracle(cx_Oracle)
    cur = con.cursor()
    
    #Obtain current user password
    res = cur.execute("select email,user_password from qcdata.users where user_name='fija.suplantar.es'")
    dataUser = res.fetchall()[0]
    userName = dataUser[0]
    userPassword = dataUser[1]
    
    #Check if there is a user suplanted
    if not userName:
        error = "There is no user supplanted. Please, use first 'Supplant'"
        return render_to_response('workflowCodeManager/error.html', {'error': error}, context_instance=RequestContext(request))
    
    
    #Set original password to the supplanted user
    cur.execute("update qcdata.users set USER_PASSWORD='******' where user_name='" + userName + "'")
    
    #Remove data from fija.suplantar.es
    cur.execute("update qcdata.users set USER_PASSWORD='', email='' where user_name='fija.suplantar.es'")
    cur.execute("commit")
    con.close()
    
    return render_to_response('workflowCodeManager/fija/supplant.html', {'active': False, 'user': userName}, context_instance=RequestContext(request))
Пример #3
0
def emailsT4U(request):
	"""Devuelve la lista de emails de los usuarios (con email definido) de T4U"""
	
	import cx_Oracle;
	con = servicios.conexOracle(cx_Oracle)
	cur = con.cursor()
	res = cur.execute("select email from qcdata.users where email is not null")
	
	emails = []
	for ren in res:
		emails.append(ren[0])
	
	con.close()
	return HttpResponse("\n".join(e for e in emails))