Skip to content

Commit ab364b9

Browse files
Merge pull request #14 from aitomatic/feat/implement_logout_cmd
Implement logout command
2 parents a6e520e + aa9c0b9 commit ab364b9

5 files changed

Lines changed: 27 additions & 4 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ Both the above commands would install the package globally and `aito` will be av
2525

2626
## How to use
2727

28-
- `aito login`: Login to Aitomatic cloud
28+
- `aito login`: Login to Aitomatic cloud
29+
- `aito logout`: Logout from Aitomatic cloud
2930
- `aito deploy app <app_name>`: Deploy app to Aitomatic cluster
3031
- `aito execute app <app_name>`: Execute app in Aitomatic cluster
3132

src/aito.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
import json
33
from src.execute.main import execute
44
from src.deploy.main import deploy
5-
from src.login.main import login, CREDENTIAL_FILE
5+
from src.login.main import login
6+
from src.logout.main import logout
7+
from src.constants import CREDENTIAL_FILE
68

79

810
def load_config():
@@ -23,6 +25,7 @@ def cli():
2325

2426

2527
cli.add_command(login)
28+
cli.add_command(logout)
2629
cli.add_command(execute)
2730
cli.add_command(deploy)
2831

src/constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from pathlib import Path
2+
3+
4+
CREDENTIAL_FILE = Path.home().joinpath('.aitomatic/credentials')

src/login/main.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@
44
from http.server import HTTPServer
55
import time
66
import json
7-
from pathlib import Path
87
from functools import update_wrapper, partial
98

109
from .server import LoginServer
1110
from src.utils import get_random_string, create_code_challenger, create_code_verifier
11+
from src.constants import CREDENTIAL_FILE
1212

1313
ORG = 'aitomaticinc.us.auth0.com'
1414
CLIENT_ID = 'zk9AB0KtNqJY0gVeF1p0ZmUb2tlcXpYq'
1515
AUDIENCE = 'https://apps.aitomatic.com/dev'
1616
SCOPE = 'openid profile email offline_access'
17-
CREDENTIAL_FILE = Path.home().joinpath('.aitomatic/credentials')
1817
PORT = 56921
1918

2019

src/logout/main.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import click
2+
3+
from src.constants import CREDENTIAL_FILE
4+
5+
6+
@click.command()
7+
@click.pass_obj
8+
def logout(obj):
9+
'''Logout from Aitomatic cloud'''
10+
if obj.get('access_token') is not None:
11+
obj['access_token'] = None
12+
obj['refresh_token'] = None
13+
obj['id'] = None
14+
if CREDENTIAL_FILE.exists():
15+
CREDENTIAL_FILE.unlink()
16+
click.echo('Logout successfully. Please login to use other commands.')

0 commit comments

Comments
 (0)