Skip to content

Commit 0657456

Browse files
committed
Use the unified gdk login call GA_login_user
1 parent 345b291 commit 0657456

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

green_cli/authenticators/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ def __init__(self, options):
2121
super().__init__()
2222

2323
def login(self, session_obj):
24-
return gdk.login(session_obj, self.hw_device, self.mnemonic, self.password)
24+
credentials = {'mnemonic': self.mnemonic, 'password': self.password}
25+
return gdk.login_user(session_obj, self.hw_device, json.dumps(credentials))
2526

2627
def register(self, session):
2728
return gdk.register_user(session, self.hw_device, self.mnemonic)

green_cli/authenticators/default.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ def login(self, session_obj):
1313
try:
1414
pin_data = open(self.pin_data_filename).read()
1515
pin = getpass("PIN: ")
16-
return gdk.login_with_pin(session_obj, pin, pin_data)
16+
credentials = {'pin': pin, 'pin_data': json.loads(pin_data)}
17+
return gdk.login_user(session_obj, '{}', json.dumps(credentials))
1718
except IOError:
1819
return super().login(session_obj)
1920

green_cli/authenticators/watchonly.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ def set_password(self, password):
1515
self._password.set(password)
1616

1717
def login(self, session_obj):
18-
return gdk.login_watch_only(session_obj, self._username.get(), self._password.get())
18+
credentials = {'username': self._username.get(), 'password': self._password.get()}
19+
return gdk.login_user(session_obj, '{}', json.dumps(credentials))
1920

2021

2122
def get_authenticator(options):

green_cli/decorators.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,7 @@ def inner(session, *args, **kwargs):
5959
if not context.logged_in:
6060
logging.info("Logging in")
6161
result = context.authenticator.login(session.session_obj)
62-
# authenticator.login attempts to abstract the actual login method, it may call
63-
# GA_login, GA_login_with_pin or GA_login_watch_only
64-
# Unfortunately only GA_login returns an auth_handler, so both cases must be handled
65-
if result:
66-
gdk_resolve(result)
62+
gdk_resolve(result)
6763
context.logged_in = True
6864

6965
if not context.no_warn_sysmsg:

0 commit comments

Comments
 (0)