I'm doing a Login with Python / Django / MongoDB this is my function
from django.shortcuts import render
from pymongo import MongoClient
import bcrypt
def login( req ):
#hashed = bcrypt.hashpw( p.encode('utf8'), bcrypt.gensalt() )
response = { 'error': 'Ni siquiera llegué' }
if req.POST['username'] and req.POST['password']:
u = req.POST['username']
p = req.POST['password']
client = MongoClient()
result = client['db']['users'].find({'nombre': u})
if result:
for res in result:
if bcrypt.checkpw( p, res['password'] ):
response = { 'error': 'Contraseña buena papus!' }
else:
response = { 'error': 'Contraseña inválida' }
break
else:
response = { 'error': 'No hay alguien con ese nombre' }
else:
response = { 'error': 'Usuario o contraseña vacío' }
return render( req, 'crawler/login.html', response )
When the variable returns to the login, it always appears 'I did not even arrive' in the error sent, as if it were ignoring all the IFs, I do not understand what is happening