mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-15 06:29:21 +02:00
Fix login in to new instance
This commit is contained in:
parent
9ec77975e5
commit
dc40e5331c
|
@ -104,7 +104,7 @@ def main():
|
||||||
if selected == 'Sign in':
|
if selected == 'Sign in':
|
||||||
print(f'''
|
print(f'''
|
||||||
If You want sign in, please visit:
|
If You want sign in, please visit:
|
||||||
https://{instance}/settings/applications/new
|
https://{current_instance.instance}/settings/applications/new
|
||||||
And fill Name funkwhale-cli
|
And fill Name funkwhale-cli
|
||||||
Scopes: Read, Write (optional): write:favorites write:listenings write:filters
|
Scopes: Read, Write (optional): write:favorites write:listenings write:filters
|
||||||
|
|
||||||
|
@ -113,13 +113,14 @@ Insert token from "Access token" here''')
|
||||||
with open('.auth.json', 'rt') as f:
|
with open('.auth.json', 'rt') as f:
|
||||||
tkns = json.loads(f.read())
|
tkns = json.loads(f.read())
|
||||||
with open('.auth.json', 'wt') as f:
|
with open('.auth.json', 'wt') as f:
|
||||||
tkns[instance] = register_token
|
tkns[current_instance.instance] = register_token
|
||||||
f.write(json.dumps(tkns))
|
f.write(json.dumps(tkns))
|
||||||
del tkns
|
del tkns
|
||||||
del register_token
|
del register_token
|
||||||
del f
|
del f
|
||||||
|
os.system('clear')
|
||||||
|
|
||||||
current_instance.select_instance(instance)
|
current_instance.select_instance(current_instance.instance)
|
||||||
if selected == 'Donate':
|
if selected == 'Donate':
|
||||||
os.system(f'less <<EOF\nSupport instance message:\n{support_message}')
|
os.system(f'less <<EOF\nSupport instance message:\n{support_message}')
|
||||||
if selected == 'About instance':
|
if selected == 'About instance':
|
||||||
|
|
|
@ -39,14 +39,14 @@ class current_instance:
|
||||||
def select_instance(new_instance=None):
|
def select_instance(new_instance=None):
|
||||||
current_instance.instance = new_instance
|
current_instance.instance = new_instance
|
||||||
with open(auth_file, 'rt') as f:
|
with open(auth_file, 'rt') as f:
|
||||||
auth = json.loads(f.read())
|
auth = json.load(f)
|
||||||
new_token = auth.get(current_instance.instance)
|
new_token = auth.get(current_instance.instance)
|
||||||
current_instance.s.headers.update({"Authorization": None})
|
current_instance.s.headers.update({"Authorization": None})
|
||||||
current_instance.token = new_token
|
current_instance.token = new_token
|
||||||
current_instance.listen_token = None
|
current_instance.listen_token = None
|
||||||
if new_token:
|
if new_token:
|
||||||
s.get(f'https://{current_instance.instance}')
|
current_instance.s.get(f'https://{current_instance.instance}')
|
||||||
s.headers.update({"Authorization": "Bearer " + new_token})
|
current_instance.s.headers.update({"Authorization": "Bearer " + new_token})
|
||||||
|
|
||||||
|
|
||||||
if current_instance.token:
|
if current_instance.token:
|
||||||
|
|
Loading…
Reference in New Issue