mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
mediawiki: Handle password rejection from MediaWiki
Closes: #2063. When admin password is being set in MediaWiki, if the password is found in the common list of passwords, MediaWiki will fail instead of setting the password. Detect this case and show an error instead of a hard server. Tests: - Setting the admin password to 'passwordpassword' fails due to check in common passwords list. A message is shown that strong password is needed instead of a 500 error page. - Set the password to 'passwordpassword' and update other settings. Settings are updated with success message but password update fails with error message. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
8875bc32ae
commit
8b7ca439ff
@ -9,6 +9,7 @@ from django.contrib import messages
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from plinth import actions, views
|
||||
from plinth.errors import ActionError
|
||||
from plinth.modules import mediawiki
|
||||
|
||||
from . import (get_default_skin, get_server_url, is_private_mode_enabled,
|
||||
@ -44,9 +45,16 @@ class MediaWikiAppView(views.AppView):
|
||||
return old_config.get(key) != new_config.get(key)
|
||||
|
||||
if new_config['password']:
|
||||
actions.superuser_run('mediawiki', ['change-password'],
|
||||
input=new_config['password'].encode())
|
||||
messages.success(self.request, _('Password updated'))
|
||||
try:
|
||||
actions.superuser_run('mediawiki', ['change-password'],
|
||||
input=new_config['password'].encode())
|
||||
messages.success(self.request, _('Password updated'))
|
||||
except ActionError as exception:
|
||||
logger.exception('Failed to update password: %s', exception)
|
||||
messages.error(
|
||||
self.request,
|
||||
_('Password update failed. Please choose a stronger '
|
||||
'password'))
|
||||
|
||||
if is_changed('enable_public_registrations'):
|
||||
# note action public-registration restarts, if running now
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user