[PATCH] [Wok] Raise 401 HTTP Error when login fails

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@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

Reviewed-By: Ramon Medeiros <ramonn@br.ibm.com> On 01/27/2016 05:42 PM, Aline Manera wrote:
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@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'])
-- Ramon Nunes Medeiros Kimchi Developer Linux Technology Center Brazil IBM Systems & Technology Group Phone : +55 19 2132 7878 ramonn@br.ibm.com
participants (2)
-
Aline Manera
-
Ramon Medeiros