mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
_clear_credentials also removes environments so logout actually works
This commit is contained in:
parent
bb5eceff95
commit
de4804f414
1 changed files with 11 additions and 4 deletions
|
|
@ -4,7 +4,8 @@ import toml
|
|||
import ftrack_api
|
||||
import appdirs
|
||||
|
||||
config_path = os.path.normpath(appdirs.user_data_dir('pype-app','pype'))
|
||||
|
||||
config_path = os.path.normpath(appdirs.user_data_dir('pype-app', 'pype'))
|
||||
config_name = 'ftrack_cred.toml'
|
||||
fpath = os.path.join(config_path, config_name)
|
||||
folder = os.path.dirname(fpath)
|
||||
|
|
@ -12,6 +13,7 @@ folder = os.path.dirname(fpath)
|
|||
if not os.path.isdir(folder):
|
||||
os.makedirs(folder)
|
||||
|
||||
|
||||
def _get_credentials():
|
||||
|
||||
folder = os.path.dirname(fpath)
|
||||
|
|
@ -21,7 +23,7 @@ def _get_credentials():
|
|||
|
||||
try:
|
||||
file = open(fpath, 'r')
|
||||
except:
|
||||
except Exception:
|
||||
filecreate = open(fpath, 'w')
|
||||
filecreate.close()
|
||||
file = open(fpath, 'r')
|
||||
|
|
@ -31,25 +33,30 @@ def _get_credentials():
|
|||
|
||||
return credentials
|
||||
|
||||
|
||||
def _save_credentials(username, apiKey):
|
||||
file = open(fpath, 'w')
|
||||
|
||||
data = {
|
||||
'username':username,
|
||||
'apiKey':apiKey
|
||||
'username': username,
|
||||
'apiKey': apiKey
|
||||
}
|
||||
|
||||
credentials = toml.dumps(data)
|
||||
file.write(credentials)
|
||||
file.close()
|
||||
|
||||
|
||||
def _clear_credentials():
|
||||
file = open(fpath, 'w').close()
|
||||
_set_env(None, None)
|
||||
|
||||
|
||||
def _set_env(username, apiKey):
|
||||
os.environ['FTRACK_API_USER'] = username
|
||||
os.environ['FTRACK_API_KEY'] = apiKey
|
||||
|
||||
|
||||
def _check_credentials(username=None, apiKey=None):
|
||||
|
||||
if username and apiKey:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue