File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change 1
1
import os
2
2
import requests
3
3
import json
4
+ import platformdirs
4
5
5
- FILENAME = "jwt_token.json"
6
- if os .name == 'nt' : # Windows
7
- TOKEN_FILE = os .path .join (os .getenv ('APPDATA' , tempfile .gettempdir ()), FILENAME )
8
- elif os .name == 'posix' : # Linux, macOS, or Android
9
- if "ANDROID_STORAGE" in os .environ : # Android
10
- TOKEN_FILE = os .path .join (os .getenv ('TMPDIR' , "/data/local/tmp" ), FILENAME )
11
- else : # Linux or macOS
12
- TOKEN_FILE = os .path .join (os .getenv ('XDG_CONFIG_HOME' , os .path .expanduser ("~/.config" )), FILENAME )
13
- else :
14
- TOKEN_FILE = os .path .join (tempfile .gettempdir (), FILENAME )
6
+ # Define your app name and author for proper directory structure
7
+ APP_NAME = "fiscalberry"
8
+ APP_AUTHOR = "fiscalberry"
9
+
10
+ # Use platformdirs to get the correct config directory
11
+ TOKEN_FILE = os .path .join (platformdirs .user_config_dir (APP_NAME , APP_AUTHOR ), "fiscalberry_jwt_token.json" )
12
+
13
+ # Ensure the directory exists
14
+ os .makedirs (os .path .dirname (TOKEN_FILE ), exist_ok = True )
15
15
16
16
def do_login (username , password ):
17
17
"""Autentica al usuario contra el backend y guarda el token JWT."""
You can’t perform that action at this time.
0 commit comments