Fix issues found while testing login pages. #6295

This commit is contained in:
Aditya Toshniwal 2023-07-11 18:12:06 +05:30 committed by GitHub
parent def1f31ba8
commit ac5be70c60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 18 additions and 11 deletions

View File

@ -7,4 +7,3 @@
'errorMessage': error_message,
} %}
{% extends "security/render_page.html" %}
{% block title %}{{ _('Authentication Registration') }}{% endblock %}

View File

@ -8,4 +8,3 @@
'csrfToken': csrf_token()
} %}
{% extends "security/render_page.html" %}
{% block title %}{{ _('Authentication') }}{% endblock %}

View File

@ -18,7 +18,8 @@ from smtplib import SMTPConnectError, SMTPResponseException, \
from socket import error as SOCKETErrorException
from urllib.request import urlopen
from pgadmin.utils.constants import KEY_RING_SERVICE_NAME, \
KEY_RING_USERNAME_FORMAT, KEY_RING_DESKTOP_USER, KEY_RING_TUNNEL_FORMAT
KEY_RING_USERNAME_FORMAT, KEY_RING_DESKTOP_USER, KEY_RING_TUNNEL_FORMAT, \
MessageType
import time
@ -46,7 +47,8 @@ from pgadmin.authenticate import get_logout_url
from pgadmin.authenticate.mfa.utils import mfa_required, is_mfa_enabled
from pgadmin.settings import get_setting, store_setting
from pgadmin.utils import PgAdminModule
from pgadmin.utils.ajax import make_json_response
from pgadmin.utils.ajax import make_json_response, internal_server_error, \
bad_request
from pgadmin.utils.csrf import pgCSRFProtect
from pgadmin.utils.preferences import Preferences
from pgadmin.utils.menu import MenuItem
@ -1103,11 +1105,14 @@ if hasattr(config, 'SECURITY_CHANGEABLE') and config.SECURITY_CHANGEABLE:
return redirect(get_url(_security.post_change_view) or
get_url(_security.post_login_view))
else:
elif errormsg is not None:
return internal_server_error(errormsg)
else:
return bad_request(list(form.errors.values())[0][0])
return make_json_response(
success=1,
info=gettext('pgAdmin user password changed successfully')
)
# Only register route if SECURITY_RECOVERABLE is set to True
if hasattr(config, 'SECURITY_RECOVERABLE') and config.SECURITY_RECOVERABLE:
@ -1194,6 +1199,10 @@ if hasattr(config, 'SECURITY_RECOVERABLE') and config.SECURITY_RECOVERABLE:
if request.get_json(silent=True) and not has_error:
return default_render_json(form, include_user=False)
for errors in form.errors.values():
for error in errors:
flash(error, MessageType.WARNING)
return _security.render_template(
config_value('FORGOT_PASSWORD_TEMPLATE'),
forgot_password_form=form,

View File

@ -325,7 +325,9 @@ export function showChangeUserPassword(url) {
url: url,
data: formData,
}).then((res)=>{
resolve(res);
resolve(res.data.info);
onClose();
Notify.success(res.data.info);
}).catch((err)=>{
reject(err);
});

View File

@ -36,7 +36,7 @@ export default function LoginPage({userLanguage, langOptions, forgotPassUrl, csr
<a style={{color: 'inherit'}} href={forgotPassUrl}>{gettext('Forgotten your password?')}</a>
</Box>
<InputSelectNonSearch name="language" options={langOptions} value={form.language} onChange={(v)=>onTextChange('language', v.target.value)} />
<SecurityButton name="internal_button" value="Login">{gettext('Login')}</SecurityButton>
<SecurityButton name="internal_button" value="Login" disabled={!(form.email && form.password)}>{gettext('Login')}</SecurityButton>
</>
}
{authSources?.includes?.(authSourcesEnum.OAUTH2) &&

View File

@ -4,5 +4,4 @@
'csrfToken': csrf_token(),
} %}
{% extends "security/render_page.html" %}
{% block title %}{{ _('Recover Password') }}{% endblock %}

View File

@ -19,4 +19,3 @@
'loginBanner': config.LOGIN_BANNER|safe
} %}
{% extends "security/render_page.html" %}
{% block title %}{{ _('Login') }}{% endblock %}

View File

@ -1,4 +1,5 @@
{% extends "base.html" %}
{% block title %}{{ config.APP_NAME }}{% endblock %}
{% set other_props = {
'messages': get_flashed_messages(with_categories=true)
} %}

View File

@ -4,5 +4,4 @@
'csrfToken': csrf_token(),
} %}
{% extends "security/render_page.html" %}
{% block title %}{{ _('Reset Password') }}{% endblock %}