From: Kanagaraj Manickam Date: Fri, 25 Sep 2020 10:11:11 +0000 (+0530) Subject: Added Login feild validations X-Git-Tag: opnfv-10.0.0~23 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F72%2F71272%2F4;p=dovetail-webportal.git Added Login feild validations Issue-ID: DOVETAIL-801 Signed-off-by: Kanagaraj Manickam Change-Id: Ifc9925d3ad8da973804919746902fd7754f98abd --- diff --git a/opnfv_testapi/common/message.py b/opnfv_testapi/common/message.py index e9b3b1c..0f50cd1 100644 --- a/opnfv_testapi/common/message.py +++ b/opnfv_testapi/common/message.py @@ -56,3 +56,11 @@ def must_int(name): def no_auth(): return 'No permission to operate. Please ask Administrator for details.' + + +def req_username(): + return 'UserName is Required' + + +def req_password(): + return 'Password is Required' diff --git a/opnfv_testapi/ui/auth/sign.py b/opnfv_testapi/ui/auth/sign.py index bd765aa..29be209 100644 --- a/opnfv_testapi/ui/auth/sign.py +++ b/opnfv_testapi/ui/auth/sign.py @@ -20,6 +20,8 @@ from opnfv_testapi.common.config import CONF from opnfv_testapi.db import api as dbapi from opnfv_testapi.ui.auth import base from opnfv_testapi.ui.auth import constants as const +from opnfv_testapi.common import raises +from opnfv_testapi.common import message import logging import oauth2 as oauth @@ -296,6 +298,10 @@ class LoginHandler(base.BaseHandler): name = data.get('name') password = data.get('pass') form_id = 'user_login' + if not name: + raises.Unauthorized(message.req_username()) + elif not password: + raises.Unauthorized(message.req_password()) params = { "name": name,