geekcomputers / geekcomputers/Python
Need help with a error in my code, that i cannot see for my self! sorry as it may be me being stupid
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 35.4k
- Fork
- 12.9k
- Merge trung bình
- 2 giờ 37 phút
- Pull request đã merge (30 ngày)
- 1
Mô tả
So, i have been making my own login system, and saving it to a txt file. i have completed the basic's nearly, Login, Register, and now i am trying to add a forget password and username functions. so basically i have a if statement that checks if the user name is in one of the files. and then sends a recovery code. well for this case its a var assigned to randint(1000,9999) thats to reset the password. then i thought what if the user forgets there username, well you get them to insert there email they signed up with and if it matches a account(in one of the saved files) it sends a code to that email(console). Reset password works fine, but trying to find the players username is hard one, im not directly trying to match the email with the username, im trying to read the file for a email that matches one that is saved. and then will pull there username after, but i havent got that far yet, as when i enter a email its not finding it, instead its finding the username, could somone please help. it could be a small error i cannot see because its so late, and im so tired, but any help would be much appreciated thx.
`import tkinter
from tkinter import*
import os
import random
from random import randint
def register_user():
username_info = username.get()
password_info = password.get()
email_info = email.get()
file=open(username_info, 'w')
file.write(username_info+'\n')
file.write(password_info+'\n')
file.write(email_info)
file.close()
username_entry.delete(0, END)
password_entry.delete(0, END)
email_entry.delete(0, END)
Label(screen1, text = 'Registration susccesful', fg = 'green', font = ('calibri', 11)).pack()
def login_verify():
username1 = username_verify.get()
password1 = password_verify.get()
username_entry1.delete(0, END)
password_entry1.delete(0, END)
list_of_files = os.listdir()
if username1 in list_of_files:
file1 = open(username1, 'r')
verify = file1.read().splitlines()
if password1 in verify:
print('Login Sucess')
else:
print('password incorrect')
else:
print('username incorrect')
def codeS():
global code
code = randint(1000, 9999)
def submit_code():
code1 = code_verify.get()
password_code.delete(0, END)
if int(code1) == code:
Label(screen4, text='Code Correct', bg='green').pack()
else:
Label(screen4, text='Wrong Code', bg='red').pack()
def change_password():
global code_verify
global password_code
code_verify = StringVar()
username2 = username_verify2.get()
username_entry2.delete(0, END)
list_of_files = os.listdir()
if username2 in list_of_files:
file2 = open(username2, 'r')
verify1 = file2.read().splitlines()
codeS()
print(code)
Label(screen4, text='Reset Code Sent').pack()
password_code = Entry(screen4, textvariable = code_verify)
password_code.pack()
Label(screen4, text='').pack()
Button(screen4, text='Submit Code', width = 10, height = 2, command=submit_code).pack()
else:
Label(screen4, text='').pack()
Label(screen4, text='No matching user name').pack()
def find_username1():
global code_verify2
global username_code
code_verify2 = StringVar()
email2 = email_verify1.get()
email_entry1.delete(0, END)
list_of_files = os.listdir()
if email2 in list_of_files:
file3 = open(email2, 'r')
verify3 = file3.read().splitlines()
print('found')
else:
Label(screen5, text='').pack()
Label(screen5, text='No matching email').pack()
def register():
global screen1
screen1 = Toplevel(screen)
screen1.title('Register')
screen1.geometry('300x250')
global username
global password
global email
global username_entry
global password_entry
global email_entry
username = StringVar()
password = StringVar()
email = StringVar()
Label(screen1, text = 'Please enter details bellow').pack()
Label(screen1, text = '').pack()
Label(screen1, text = 'Username *').pack()
username_entry = Entry(screen1, textvariable = username)
username_entry.pack()
Label(screen1, text = 'Password *').pack()
password_entry = Entry(screen1, textvariable = password)
password_entry.pack()
Label(screen1, text = 'Email *').pack()
email_entry = Entry(screen1, textvariable = email)
email_entry.pack()
Label(screen1, text = '').pack()
Button(screen1, text = 'Register', width = 10, height = 1, command = register_user).pack()
def reset_password():
global screen4
screen4 = Toplevel(screen)
screen4.title('Reset Password')
screen4.geometry('300x250')
Label(screen4, text='Enter username *', height = 2, width = 30).pack()
global username_entry2
global username_verify2
username_verify2 = StringVar()
username_entry2 = Entry(screen4, textvariable = username_verify2)
username_entry2.pack()
Label(screen4, text='').pack()
Button(screen4, text='Reset Password', command=change_password).pack()
def forgot_user():
global screen5
screen5 = Toplevel(screen)
screen5.title('Find Username')
screen5.geometry('300x250')
Label(screen5, text='Enter Email *', height=2, width=30).pack()
global email_entry1
global email_verify1
email_verify1 = StringVar()
email_entry1 = Entry(screen5, textvariable = email_verify1, width=30)
email_entry1.pack()
Label(screen5, text='').pack()
Button(screen5, text='Find Username', command=find_username1).pack()
def login_issue():
global screen3
screen3 = Toplevel(screen)
screen3.title('Login Issues')
screen3.geometry('350x250')
Label(screen3, text='Have you forgot your username or password?', bg = 'grey', width = '350', height = '2', font = ('Calibri', 13)).pack()
Label(screen3, text = '').pack()
Button(screen3, text = 'Username', width = 30, height = 2, command = forgot_user).pack()
Label(screen3, text = '').pack()
Button(screen3, text = 'Password', width = 30, height = 2, command = reset_password).pack()
def login():
global screen2
screen2 = Toplevel(screen)
screen2.title('Login')
screen2.geometry('300x250')
Label(screen2, text = 'Please enter details bellow to login').pack()
Label(screen2, text = '').pack()
global username_verify
global password_verify
username_verify = StringVar()
password_verify = StringVar()
global username_entry1
global password_entry1
Label(screen2, text = 'Username * ').pack()
username_entry1 = Entry(screen2, textvariable = username_verify)
username_entry1.pack()
Label(screen2, text = '').pack()
Label(screen2, text = 'Password * ').pack()
password_entry1 = Entry(screen2, textvariable = password_verify)
password_entry1.pack()
Label(screen2, text = '').pack()
Button(screen2, text = 'Login', width = 10, height = 1, command = login_verify).pack()
Label(screen2, text = '').pack()
Button(screen2, text = 'Login issue?', width = 10, height = 1, command=login_issue).pack()
def main_screen():
global screen
screen = Tk()
screen.geometry('300x250')
screen.title('Login API 1.2')
Label(text = 'Login 1.2', bg = 'grey', width = '300', height = '2', font = ('Calibri', 13)).pack()
Label(text = '').pack()
Button(text = 'Login', height = '2', width = '30', command=login).pack()
Label(text = '').pack()
Button(text = 'Register', height = '2', width = '30', command=register).pack()
screen.mainloop()
main_screen()
`
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Điểm vào liên quan là find_username1() trong script được cung cấp; hãy so sánh thao tác tra cứu của nó với register_user(), hàm ghi tên người dùng, mật khẩu và email vào các tệp được đặt tên theo tên người dùng. Chạy luồng quên tên người dùng với một tài khoản đã đăng ký và làm cho hành vi hoàn tất xác định tên người dùng được liên kết với email đã nhập.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- desktop
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100