diff --git a/luna.py b/luna.py index 65650cc..f960aea 100644 --- a/luna.py +++ b/luna.py @@ -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, @@ -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") @@ -380,9 +383,11 @@ 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 @@ -390,11 +395,13 @@ def joinClick(e): 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 @@ -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 @@ -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 diff --git a/lunaData.db b/lunaData.db index 7aa493d..4d116ab 100644 Binary files a/lunaData.db and b/lunaData.db differ diff --git a/settings.py b/settings.py index 103eb4f..7897f60 100644 --- a/settings.py +++ b/settings.py @@ -6,6 +6,7 @@ serverPasswordRequired = False serverPassword = "server_password_here" displayServerAddressOnLogin = True +enableAccounts = False # Flags lunaExperimentalColorOverride = False