29 lines
1.0 KiB
Python
29 lines
1.0 KiB
Python
from kivy.uix.screenmanager import Screen
|
|
from kivy.uix.boxlayout import BoxLayout
|
|
from kivy.uix.label import Label
|
|
from kivy.uix.button import Button
|
|
from kivy.uix.popup import Popup
|
|
from kivy.uix.image import Image
|
|
from kivy.uix.behaviors import ButtonBehavior
|
|
from kivy.clock import Clock
|
|
import os
|
|
import json
|
|
from config import RESOURCES_FOLDER, CREDENTIALS_FILE
|
|
from py_scripts.utils import encrypt_data, decrypt_data, check_server_settings, save_server_settings, test_connection
|
|
|
|
|
|
class LoginScreen(Screen):
|
|
def login(self):
|
|
username = self.ids.username_input.text.strip()
|
|
password = self.ids.username_input.text.strip()
|
|
|
|
if not username or not password:
|
|
self.manager.get_screen("home").ids.result_label.text = "Please fill in all fields."
|
|
return
|
|
|
|
credentials = {"username": username, "password": password}
|
|
encrypted_data = encrypt_data(json.dumps(credentials))
|
|
with open(CREDENTIALS_FILE, "wb") as file:
|
|
file.write(encrypted_data)
|
|
|
|
self.manager.current = "home" |