Skip to content

Commit

Permalink
ajuste na lógica redefinir senha para recuperar conta
Browse files Browse the repository at this point in the history
Co-authored-by: mandicrz <[email protected]>
  • Loading branch information
CaioDuart3 and mandicrz committed Dec 8, 2024
1 parent 9209019 commit 9eee1ed
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
Binary file modified mamutes/Users/__pycache__/views.cpython-312.pyc
Binary file not shown.
32 changes: 16 additions & 16 deletions mamutes/Users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ def login (request):
username = request.POST.get('username')
senha = request.POST.get('password')

print(username, senha)
user = authenticate(username=username, password=senha)


if user is not None:
login_django (request, user)
return render(request, 'login.html')
return HttpResponse("boa paizao deu certo")

else:
return HttpResponse("Credenciais inválidas.")
Expand Down Expand Up @@ -70,30 +68,32 @@ def recuperarConta(request):
'mensagem': f'Este email não existe, é necessário que o email tenha registro no sistema para recuperá-lo.',
}
return render(request, 'recuperarConta.html', context)

def redefinirSenha(request, username, token):
usuario = MembroEquipe.objects.get(username=username)
gerador = PasswordResetTokenGenerator()

if gerador.check_token(usuario, token):
return render(request, 'redefinirSenha.html')

if request.method == "POST":
senha = request.POST.get("password1")
confirmar_senha = request.POST.get("password2")

if senha != confirmar_senha:
return render(request, 'redefinirSenha.html',{
print('As senhas não coincidem')
return render(request, 'redefinirSenha.html', {
"username": username,
"token": token,
"mensagem": 'As senhas precisam ser iguais, tente novamente.'
"mensagem": "As senhas não coincidem."
})

usuario.set_password(senha)
usuario.save(force_update=True)
usuario.save()
print('Senha redefinida com sucesso')
return redirect("login")

return render(request, 'redefinirSenha.html', {
"username": username,
"token": token,
})

if gerador.check_token(usuario, token):
print('Token válido')
return render(request, 'redefinirSenha.html', {
"username": username,
"token": token,
})

return redirect("login")
Binary file modified mamutes/db.sqlite3
Binary file not shown.

0 comments on commit 9eee1ed

Please sign in to comment.