From f99c3f74981b17803a3b4beb5f186008e188fa36 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Tue, 7 Apr 2020 13:46:33 +0200 Subject: [PATCH] Handle authentication errors better. --- fulbank/auth.py | 3 +++ fulbank/fsb.py | 2 +- netbank | 6 +++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/fulbank/auth.py b/fulbank/auth.py index 10c1afe..013b873 100644 --- a/fulbank/auth.py +++ b/fulbank/auth.py @@ -1,5 +1,8 @@ import sys, os, io, termios +class autherror(Exception): + pass + class conv(object): msg_notice = 0 msg_info = 1 diff --git a/fulbank/fsb.py b/fulbank/fsb.py index 4a91278..834536a 100644 --- a/fulbank/fsb.py +++ b/fulbank/fsb.py @@ -11,7 +11,7 @@ serviceid = "B7dZHQcY78VRVz9l" class fmterror(Exception): pass -class autherror(Exception): +class autherror(auth.autherror): pass class jsonerror(Exception): diff --git a/netbank b/netbank index 4215a3c..a1d3566 100755 --- a/netbank +++ b/netbank @@ -63,7 +63,11 @@ def cmd_login(cmd, args): sys.stderr.write("usage: login bankid USER-ID\n") sys.exit(1) with auth.ttyconv() as conv: - sess.auth_bankid(args[1], conv) + try: + sess.auth_bankid(args[1], conv) + except auth.autherror as err: + sys.stderr.write("netbank: authentication failed: %s\n" % err) + sys.exit(1) else: sys.stderr.write("netbank: %s: unknown authentication type\n" % (args[0])) sys.exit(1) -- 2.11.0