Compare commits

..

No commits in common. "7f7b8733b698127c1537285bd631f633fe23406f" and "f748e48517a6630b2cadc969e86e61fd0ae55b83" have entirely different histories.

2 changed files with 0 additions and 104 deletions

View file

@ -1,104 +0,0 @@
import psycopg2
import os
import json
import customtkinter
from winotify import Notification, audio
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
self.title("Dislocker ロック中")
self.attributes('-fullscreen', True)
Lock()
def exit(self):
self.toast()
self.destroy()
def toast(self):
resource_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "resource")
success = Notification(
app_id='Dislocker',
title='ご協力ありがとうございます!',
msg='パスワード認証に成功しました。\n現在使われたパスワードは削除されます。',
icon=resource_path + r'\success.png'
)
success.set_audio(audio.Default, loop=False)
success.show()
class Lock(customtkinter.CTkToplevel):
def __init__(self):
super().__init__()
self.title('Dislocker | PC番号 10 | ロックされています')
self.geometry('400x500')
self.resizable(height=False, width=False)
self.lift()
self.msg_title_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
self.msg_title_frame.grid(row=0, column=0, sticky="nsew")
self.msg_title_1 = customtkinter.CTkLabel(self.msg_title_frame, text='ちょっと待って!!')
self.msg_title_1.grid(row=0, column=0, padx=10, pady=10)
self.msg_subtitle_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
self.msg_subtitle_frame.grid(row=1, column=0, sticky="nsew")
self.msg_subtitle_1 = customtkinter.CTkLabel(self.msg_subtitle_frame, text='サインインするには、パスワードが必要です。')
self.msg_subtitle_1.grid(row=0, column=0, padx=10, pady=10)
self.input_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
self.input_frame.grid(row=2, column=0, sticky="nsew")
self.password_entry = customtkinter.CTkEntry(self.input_frame, placeholder_text='パスワード', width=380)
self.password_entry.grid(row=0, column=0, padx=10, pady=10)
self.button_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
self.button_frame.grid(row=3, column=0, sticky="nsew")
self.signin_button = customtkinter.CTkButton(self.button_frame, text='サインイン', command=self.auth)
self.signin_button.grid(row=0, column=0, padx=10, pady=10)
def auth(self):
self.db = psycopg2.connect(f"host={db_config["host"]} dbname={db_config["db"]} port={db_config["port"]} user={db_config["username"]} password={db_config["password"]}")
cursor = self.db.cursor()
cursor.execute("SELECT * FROM pc_list WHERE pc_number = %s", (10,))
pc_info = cursor.fetchall()
auth_password = str(self.password_entry.get())
if pc_info[0][2] == auth_password:
cursor.execute("UPDATE pc_list SET password_hash = NULL WHERE pc_number = %s", (10,))
app.notify()
self.db.commit()
self.destroy()
app.exit()
else:
self.msg_subtitle_1.configure(text='サインインするには、パスワードが必要です。\nパスワードが違います!')
config_dir_path = "./config/"
db_config_path = config_dir_path + "db.json"
if not os.path.isfile(db_config_path):
if not os.path.isdir(config_dir_path):
os.mkdir(config_dir_path)
db_config = {
"host": "localhost",
"db": "dislocker",
"username": "user",
"password": "example_pass",
"port": "5432"
}
with open(db_config_path, "w") as w:
json.dump(db_config, w, indent=4)
elif os.path.isfile(db_config_path):
with open(db_config_path, "r") as r:
db_config = json.load(r)
if __name__ == '__main__':
app = App()
app.mainloop()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB