パスワードをハッシュ化してデータベースに保存するように
This commit is contained in:
parent
26902aa0b3
commit
9dec6938dd
1 changed files with 6 additions and 4 deletions
10
dislocker.py
10
dislocker.py
|
@ -38,6 +38,7 @@ class Bot(discord.Client):
|
||||||
if msg_split[1].isdigit() and msg_split[2].isdigit():
|
if msg_split[1].isdigit() and msg_split[2].isdigit():
|
||||||
if int(msg_split[1]) <= 10 and int(msg_split[1]) >= 1:
|
if int(msg_split[1]) <= 10 and int(msg_split[1]) >= 1:
|
||||||
password = self.password_generate(4)
|
password = self.password_generate(4)
|
||||||
|
password_hash = self.hash_genarate(password)
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
cursor.execute("SELECT * FROM club_member WHERE discord_userid = %s", (str(message.author.id),))
|
cursor.execute("SELECT * FROM club_member WHERE discord_userid = %s", (str(message.author.id),))
|
||||||
member_info = cursor.fetchall()
|
member_info = cursor.fetchall()
|
||||||
|
@ -48,7 +49,7 @@ class Bot(discord.Client):
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
cursor.execute("UPDATE pc_list SET using_user_id = %s WHERE pc_number = %s", (member_info[0][0], msg_split[1]))
|
cursor.execute("UPDATE pc_list SET using_user_id = %s WHERE pc_number = %s", (member_info[0][0], msg_split[1]))
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
cursor.execute("UPDATE pc_list SET password_hash = %s WHERE pc_number = %s", (password, msg_split[1]))
|
cursor.execute("UPDATE pc_list SET password_hash = %s WHERE pc_number = %s", (password_hash, msg_split[1]))
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
|
|
||||||
await message.channel.send(f"使用が開始されました。\nパスワード | {password}\nPC番号 | {msg_split[1]}\nデバイス番号 | {msg_split[2]}\n")
|
await message.channel.send(f"使用が開始されました。\nパスワード | {password}\nPC番号 | {msg_split[1]}\nデバイス番号 | {msg_split[2]}\n")
|
||||||
|
@ -61,7 +62,7 @@ class Bot(discord.Client):
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
cursor.execute("UPDATE pc_list SET using_user_id = %s WHERE pc_number = %s", (member_info[0][0], msg_split[1]))
|
cursor.execute("UPDATE pc_list SET using_user_id = %s WHERE pc_number = %s", (member_info[0][0], msg_split[1]))
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
cursor.execute("UPDATE pc_list SET password_hash = %s WHERE pc_number = %s", (password, msg_split[1]))
|
cursor.execute("UPDATE pc_list SET password_hash = %s WHERE pc_number = %s", (password_hash, msg_split[1]))
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
|
|
||||||
await message.channel.send(f"使用が開始されました。\nパスワード | {password}\nPC番号 | {msg_split[1]}\nデバイス番号 | {msg_split[2]}\n")
|
await message.channel.send(f"使用が開始されました。\nパスワード | {password}\nPC番号 | {msg_split[1]}\nデバイス番号 | {msg_split[2]}\n")
|
||||||
|
@ -75,6 +76,7 @@ class Bot(discord.Client):
|
||||||
if msg_split[1].isdigit() and msg_split[2].isdigit():
|
if msg_split[1].isdigit() and msg_split[2].isdigit():
|
||||||
if int(msg_split[1]) <= 10 and int(msg_split[1]) >= 1:
|
if int(msg_split[1]) <= 10 and int(msg_split[1]) >= 1:
|
||||||
password = self.password_generate(4)
|
password = self.password_generate(4)
|
||||||
|
password_hash = self.hash_genarate(password)
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
cursor.execute("SELECT * FROM club_member WHERE discord_userid = %s", (str(message.author.id),))
|
cursor.execute("SELECT * FROM club_member WHERE discord_userid = %s", (str(message.author.id),))
|
||||||
member_info = cursor.fetchall()
|
member_info = cursor.fetchall()
|
||||||
|
@ -85,7 +87,7 @@ class Bot(discord.Client):
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
cursor.execute("UPDATE pc_list SET using_user_id = %s WHERE pc_number = %s", (member_info[0][0], msg_split[1]))
|
cursor.execute("UPDATE pc_list SET using_user_id = %s WHERE pc_number = %s", (member_info[0][0], msg_split[1]))
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
cursor.execute("UPDATE pc_list SET password_hash = %s WHERE pc_number = %s", (password, msg_split[1]))
|
cursor.execute("UPDATE pc_list SET password_hash = %s WHERE pc_number = %s", (password_hash, msg_split[1]))
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
|
|
||||||
await message.channel.send(f"使用が開始されました。\nパスワード | {password}\nPC番号 | {msg_split[1]}\nデバイス番号 | {msg_split[2]}\n")
|
await message.channel.send(f"使用が開始されました。\nパスワード | {password}\nPC番号 | {msg_split[1]}\nデバイス番号 | {msg_split[2]}\n")
|
||||||
|
@ -97,7 +99,7 @@ class Bot(discord.Client):
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
cursor.execute("UPDATE pc_list SET using_user_id = %s WHERE pc_number = %s", (member_info[0][0], msg_split[1]))
|
cursor.execute("UPDATE pc_list SET using_user_id = %s WHERE pc_number = %s", (member_info[0][0], msg_split[1]))
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
cursor.execute("UPDATE pc_list SET password_hash = %s WHERE pc_number = %s", (password, msg_split[1]))
|
cursor.execute("UPDATE pc_list SET password_hash = %s WHERE pc_number = %s", (password_hash, msg_split[1]))
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
await message.channel.send(f"使用が開始されました。\nパスワード | {password}\nPC番号 | {msg_split[1]}\nデバイス番号 | {msg_split[2]}\n")
|
await message.channel.send(f"使用が開始されました。\nパスワード | {password}\nPC番号 | {msg_split[1]}\nデバイス番号 | {msg_split[2]}\n")
|
||||||
await self.get_channel(bot_config["log_channel_id"]).send(f'{member_info[0][2]}がPC{msg_split[1]}を使用しています')
|
await self.get_channel(bot_config["log_channel_id"]).send(f'{member_info[0][2]}がPC{msg_split[1]}を使用しています')
|
||||||
|
|
Loading…
Reference in a new issue