diff options
-rw-r--r-- | opnfv_testapi/common/message.py | 8 | ||||
-rw-r--r-- | opnfv_testapi/ui/auth/sign.py | 6 |
2 files changed, 14 insertions, 0 deletions
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, |