Handle authentication errors better. master
authorFredrik Tolf <fredrik@dolda2000.com>
Tue, 7 Apr 2020 11:46:33 +0000 (13:46 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Tue, 7 Apr 2020 11:46:33 +0000 (13:46 +0200)
fulbank/auth.py
fulbank/fsb.py
netbank

index 10c1afe..013b873 100644 (file)
@@ -1,5 +1,8 @@
 import sys, os, io, termios
 
+class autherror(Exception):
+    pass
+
 class conv(object):
     msg_notice = 0
     msg_info = 1
index 4a91278..834536a 100644 (file)
@@ -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 (executable)
--- 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)