diff --git a/web/pgadmin/authenticate/__init__.py b/web/pgadmin/authenticate/__init__.py index 0d5b429c0..5e891a99c 100644 --- a/web/pgadmin/authenticate/__init__.py +++ b/web/pgadmin/authenticate/__init__.py @@ -289,6 +289,10 @@ class AuthSourceManager: if msg is not None and 'username' in msg: self.form._fields['email'].data = msg['username'] return status, msg + else: + current_app.logger.debug( + "Authentication initiated via source: %s is failed." % + source.get_source_name()) return status, msg diff --git a/web/pgadmin/authenticate/internal.py b/web/pgadmin/authenticate/internal.py index 303137b41..9c4542dff 100644 --- a/web/pgadmin/authenticate/internal.py +++ b/web/pgadmin/authenticate/internal.py @@ -106,8 +106,9 @@ class InternalAuthentication(BaseAuthentication): def authenticate(self, form): username = form.data['email'] - user = getattr(form, 'user', - User.query.filter_by(username=username).first()) - if user and user.is_authenticated and form.validate_on_submit(): - return True, None + if form.validate_on_submit(): + user = getattr(form, 'user', + User.query.filter_by(username=username).first()) + if user and user.is_authenticated: + return True, None return False, self.messages('USER_DOES_NOT_EXIST')