Ensure that internal users are able to login when auth sources are [ldap, internal]. #6151

This commit is contained in:
Yogesh Mahajan 2023-04-24 11:54:02 +05:30 committed by GitHub
parent 62baa0dccb
commit 39a0f46159
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

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

View File

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