mirror of
https://github.com/szymon-jozef/zutui.git
synced 2026-09-07 12:10:43 +02:00
Compare commits
6 Commits
fix/linux-
...
deb7433d3e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
deb7433d3e | ||
| 3506d1f5ea | |||
| 876463d7c5 | |||
| ec01f9a7da | |||
| 196482f9e2 | |||
| 30b2ef6afd |
13
README.md
13
README.md
@@ -30,17 +30,12 @@ zutui
|
||||
`ctrl`+`q` - Quit
|
||||
|
||||
# Sidenotes
|
||||
- config is stored @ `~/zutui/config.json`
|
||||
## Config
|
||||
- On Unix like is stored @ `~/.config/zutui/config.json`
|
||||
- On Windows is stored @ `~/zutui/config.json`
|
||||
- so are `grades_cache.json`
|
||||
- in plaintext.....
|
||||
|
||||
##### As of right now I don't see any MUCH better way.
|
||||
|
||||
##### I mean we could simply encrypt and decrypt it during runtime, but... does it really make it any more secure?
|
||||
|
||||
##### And we can't really store it in any form of a _hash_ as we have to log in everytime with plain text anyways...
|
||||
|
||||
##### However feel free to pull request if you're smarter :)
|
||||
##### Feel free to pull request if you're smarter :)
|
||||
|
||||
# TODO:
|
||||
- [x] **Nothing**
|
||||
|
||||
4
setup.py
4
setup.py
@@ -8,10 +8,12 @@ setup(
|
||||
"requests",
|
||||
"beautifulsoup4",
|
||||
"textual",
|
||||
"keyring",
|
||||
"pywin32"
|
||||
],
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'zutui=zut_app.zutui:main',
|
||||
],
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import json
|
||||
import os
|
||||
import keyring
|
||||
from keyring.errors import KeyringError
|
||||
from datetime import datetime
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Container
|
||||
@@ -54,9 +56,20 @@ class LoginScreen(Screen):
|
||||
if success:
|
||||
try:
|
||||
with open(CONFIG_FILE, "w") as f:
|
||||
json.dump({"username": user, "password": password}, f)
|
||||
json.dump({"username": user}, f)
|
||||
keyring.set_password("zutui", user, password)
|
||||
except KeyringError as e:
|
||||
error = e
|
||||
self.app.call_from_thread(
|
||||
lambda:
|
||||
self.app.notify(
|
||||
f"Błąd: {str(error)}",
|
||||
title="Błąd zapisu hasła do systemowego menedżera haseł",
|
||||
severity="warning",
|
||||
timeout=5
|
||||
)
|
||||
)
|
||||
except: pass
|
||||
|
||||
def do_switch():
|
||||
self.app.switch_screen(DashboardScreen())
|
||||
self.app.call_from_thread(do_switch)
|
||||
@@ -406,7 +419,10 @@ class ZutApp(App):
|
||||
try:
|
||||
with open(CONFIG_FILE, "r") as f:
|
||||
creds = json.load(f)
|
||||
self.zut_client = ZUT(creds["username"], creds["password"])
|
||||
password = keyring.get_password("zutui", creds["username"])
|
||||
if password is None:
|
||||
raise ValueError("Hasło nie zostało znalezione")
|
||||
self.zut_client = ZUT(creds["username"], password)
|
||||
self.push_screen(DashboardScreen())
|
||||
except:
|
||||
self.push_screen(LoginScreen())
|
||||
|
||||
Reference in New Issue
Block a user