Skip to content

Commit

Permalink
Server password input updated
Browse files Browse the repository at this point in the history
  • Loading branch information
detectiveren committed Jun 3, 2024
1 parent 2d80eda commit 70640f6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
27 changes: 24 additions & 3 deletions luna.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def __init__(self, message: LunaMessage):
[
ft.Text(message.lunaUser, color=UsernameColor),
# The username that will pop up in the message container
ft.Text(message.lunaText, selectable=True, color=chatMessageColor)
ft.Text(message.lunaText, selectable=True)
# The message that will pop up in the message container
],
tight=True,
Expand Down Expand Up @@ -236,6 +236,9 @@ def loadDatabase():
print(row)


if settings.enableAccounts:
loadDatabase()

print("loaded classes LunaMessage, LunaChatMessage, LunaImageMessage and LunaVideoMessage, message container has been "
"created")

Expand Down Expand Up @@ -380,21 +383,25 @@ def joinClick(e):
if not lunaUsername.value:
lunaUsername.error_text = "USERNAME CANNOT BE BLANK"
lunaUsername.update()
lunaUsername.value = ""
elif "lunaBOT" in lunaUsername.value: # If the user input is lunaBOT it will return an error
lunaUsername.error_text = "USERNAME INVALID"
lunaUsername.update()
lunaUsername.value = ""
print("LOG (Login System) Anonymous user tried to log in but the username was invalid")
elif lunaUsername.value.strip() in usernamesInUse:
# If the username is found in the usernamesInUse list then the username is in use
lunaUsername.error_text = "USERNAME IN USE"
lunaUsername.update()
print(f"LOG (Login System) Anonymous user tried to log in with the username {lunaUsername.value.strip()}"
f" but it was already in use")
lunaUsername.value = ""
elif lunaUsername.value.strip() in bannedUsername:
lunaUsername.error_text = "USERNAME IS BANNED"
lunaUsername.update()
print(f"LOG (Login System) Anonymous user tried to log in with the username {lunaUsername.value.strip()}"
f" but the username is banned")
lunaUsername.value = ""
else:
page.session.set("lunaUsername", lunaUsername.value) # Takes in the username value that was entered
page.dialog.open = False
Expand Down Expand Up @@ -441,9 +448,12 @@ def joinClick(e):
videoFormats = [".mp4"]
lunaUsername = ft.TextField(label="Enter your username", color=messageTypeColor, bgcolor=dialogMessageBoxColor,
label_style=ft.TextStyle(size=15, color=messageTypeColor), on_submit=joinClick)
lunaPassword = ft.TextField(label="Enter your password", color=messageTypeColor, bgcolor=dialogMessageBoxColor,
label_style=ft.TextStyle(size=15, color=messageTypeColor), on_submit=joinClick, password=True,
can_reveal_password=True)
lunaServerPassword = ft.TextField(label="Enter password", color=messageTypeColor, bgcolor=dialogMessageBoxColor,
label_style=ft.TextStyle(size=15, color=messageTypeColor),
on_submit=passwordCheck)
on_submit=passwordCheck, password=True, can_reveal_password=True)

page.title = "lunaChat"
page.bgcolor = pageBackgroundColor
Expand All @@ -458,11 +468,22 @@ def joinClick(e):
bgcolor=dialogColor,
title=ft.Text("Welcome to lunaChat!", color=titleTextColor),
content=ft.Column([lunaUsername], tight=True),
actions=[ft.ElevatedButton(text="Join lunaChat", on_click=joinClick, color=ft.colors.PINK,
actions=[ft.ElevatedButton(text="Login to lunaChat", on_click=joinClick, color=ft.colors.PINK,
bgcolor=dialogButtonColor)],
actions_alignment="end",
) # Opens the alert dialog welcoming the user to lunaChat and takes the input from the user which is the username

register = ft.AlertDialog(
open=True,
modal=True,
bgcolor=dialogColor,
title=ft.Text("Register an account on lunaChat!", color=titleTextColor),
content=ft.Column([lunaUsername, lunaPassword], tight=True),
actions=[ft.ElevatedButton(text="Join lunaChat", on_click=joinClick, color=ft.colors.PINK,
bgcolor=dialogButtonColor)],
actions_alignment="end",
)

def loginDialog(): # Display the login alert dialog
page.dialog = login
login.open = True
Expand Down
Binary file modified lunaData.db
Binary file not shown.
1 change: 1 addition & 0 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
serverPasswordRequired = False
serverPassword = "server_password_here"
displayServerAddressOnLogin = True
enableAccounts = False
# Flags
lunaExperimentalColorOverride = False

0 comments on commit 70640f6

Please sign in to comment.