0
I have a registration program that receives the user’s data (e-mail and password), this data goes to a file . txt, with the function Open() python, example:
txt file
[email protected], senha1234
[email protected], 12345678
First the user’s email is written then comes a "," to separate the email from the password.
After the user registers he needs to log in. Here’s the problem, how can I do to check inside the file .txt
if the password the user entered in the login matches his email address?
Code
import PySimpleGUI as sg
def Login():
sg.theme('Black')
layout = [
[sg.Text('E-mail'), sg.Input(size=(25,5), key='email')],
[sg.Text('Senha'), sg.Input(size=(25,0), key='Pass')],
[sg.Button('Log-in')]
]
# Gerar Janela
janela = sg.Window('Log-in', layout)
button, values = janela.Read()
# Armazenando valores
email = values['email']
Pass = values['Pass']
# Condicionais
if '@gmail.com' not in email[-10:]:
pass
elif len(Pass) < 8:
print('Senha deve conter 8 ou mais caracteres')
else:
with open(r'Works\Log-in\obb\bcdds.txt', 'r', encoding='utf-8') as file:
dados = file.read()
if email not in dados:
print('E-mail não cadastrado.')
elif Pass:
**Aqui vem a checagem para saber se a senha corresponde ao email**