[Kimchi-devel] [PATCH] [Wok] Raise 401 HTTP Error when login fails

Aline Manera alinefm at linux.vnet.ibm.com
Wed Jan 27 19:42:39 UTC 2016


When using the REST API to login into Wok, on any error the return code was
wrongly set to 500, due the OperationFailed exception.
Fix it.

Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
---
 src/wok/auth.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/wok/auth.py b/src/wok/auth.py
index afd4cf4..3f1c8d5 100644
--- a/src/wok/auth.py
+++ b/src/wok/auth.py
@@ -70,8 +70,8 @@ class User(object):
                     if not klass.authenticate(**auth_args):
                         debug("cannot verify user with the given password")
                         return None
-                except OperationFailed:
-                    raise
+                except OperationFailed, e:
+                    raise cherrypy.HTTPError(401, e.message)
                 return klass(auth_args['username'])
 
 
-- 
2.5.0




More information about the Kimchi-devel mailing list