Permalink
Browse files

Item14506: More param validation, and move messages into templates.

  • Loading branch information...
1 parent f659d6a commit 81de4e23981fe541bc99de76b780a0a29541820a @gac410 gac410 committed Oct 13, 2017
@@ -44,13 +44,19 @@ sub _RESTresetPassword {
my $users = $session->{users};
unless ( $Foswiki::cfg{EnableEmail} ) {
- my $err = $session->i18n->maketext(
- 'Email has been disabled for this Foswiki installation');
throw Foswiki::OopsException(
'password',
topic => $Foswiki::cfg{HomeTopicName},
- def => 'reset_bad',
- params => [$err]
+ def => 'email_disabled',
+ );
+ }
+
+ if ( !$session->inContext('passwords_modifyable') ) {
+ throw Foswiki::OopsException(
+ 'password',
+ web => $session->{webName},
+ topic => $session->{topicName},
+ def => 'passwords_disabled'
);
}
@@ -70,10 +76,7 @@ sub _RESTresetPassword {
if ( scalar @$cuidList > 1 ) {
throw Foswiki::OopsException(
'password',
- topic => $Foswiki::cfg{HomeTopicName},
- def => 'reset_bad',
- params =>
- ['The entered email address is not unique. Use a WikiName']
+ def => 'non_unique_email',
);
}
else {
@@ -84,11 +87,7 @@ sub _RESTresetPassword {
throw Foswiki::OopsException(
'password',
status => 200,
- topic => $Foswiki::cfg{HomeTopicName},
- def => 'reset_bad',
- params => [
-'This Foswiki is not configured to permit access by email address. Please enter a WikiName or Login name.'
- ],
+ def => 'email_not_supported',
);
}
@@ -222,6 +221,15 @@ sub _RESTchangePassword {
);
}
+ if ( !$session->inContext('passwords_modifyable') ) {
+ throw Foswiki::OopsException(
+ 'password',
+ web => $session->{webName},
+ topic => $session->{topicName},
+ def => 'passwords_disabled'
+ );
+ }
+
my $users = $session->{users}; # Get the Foswiki::Users object
my $user = Foswiki::Func::getCanonicalUserID($login);
@@ -3,24 +3,56 @@
SYSTEM MESSAGES related to Password Change and Reset.
}%
%{==============================================================================}%
+%TMPL:DEF{"email_disabled"}%
+---+++ %MAKETEXT{"Email disabled"}%
+
+%MAKETEXT{"The Administrator has disabled email on this system. Password reset is not supported."}%
+
+%MAKETEXT{"Please contact [_1]." args="%WIKIWEBMASTER%"}%
+
+%MAKETEXT{"Your password has not been changed."}%
+
+*[[%TOPIC%][%MAKETEXT{"OK"}%]]*
+%TMPL:END%
+%{==============================================================================}%
%TMPL:DEF{"passwords_disabled"}%
---+++ %MAKETEXT{"Passwords disabled"}%
-%MAKETEXT{"The Administrator has disabled password changes."}%
+%MAKETEXT{"The Administrator has disabled password changes. Password change and reset are not supported."}%
%MAKETEXT{"Please contact [_1]." args="%WIKIWEBMASTER%"}%
%MAKETEXT{"Your password has not been changed."}%
+
+*[[%TOPIC%][%MAKETEXT{"OK"}%]]*
%TMPL:END%
%{==============================================================================}%
%TMPL:DEF{"no_users_to_reset"}%
---+++ %MAKETEXT{"Password reset failed"}%
%MAKETEXT{"No users to reset passwords for."}%
+
+%MAKETEXT{"Please go back in your browser and try again."}%
%TMPL:END%
%{==============================================================================}%
%TMPL:DEF{"reset_bad"}%
---+++ %MAKETEXT{"Password reset failed."}%
%PARAM1%
+
+%MAKETEXT{"Please go back in your browser and try again."}%
+%TMPL:END%
+%{==============================================================================}%
+%TMPL:DEF{"non_unique_email"}%
+---+++ %MAKETEXT{"Password reset failed"}%
+%MAKETEXT{"Multiple users share the entered email address. Please used your !WikiName to reset your password."}%
+
+%MAKETEXT{"Please go back in your browser and try again."}%
+%TMPL:END%
+%{==============================================================================}%
+%TMPL:DEF{"email_not_supported"}%
+---+++ %MAKETEXT{"Password reset failed"}%
+%MAKETEXT{"This Foswiki is not configured to permit login by email address. Please enter a WikiName or Login name to reset the password."}%
+
+%MAKETEXT{"Please go back in your browser and try again."}%
%TMPL:END%
%{==============================================================================}%
%TMPL:DEF{"password_mismatch"}%
@@ -65,18 +65,6 @@ sub manage {
}
}
-sub _action_changePassword {
- my $session = shift;
- require Foswiki::UI::Passwords;
- Foswiki::UI::Passwords::changePasswordAndOrEmail($session);
-}
-
-sub _action_resetPassword {
- my $session = shift;
- require Foswiki::UI::Passwords;
- Foswiki::UI::Passwords::resetPassword($session);
-}
-
sub _action_bulkRegister {
my $session = shift;
require Foswiki::UI::Register;
@@ -674,7 +662,7 @@ sub _action_restoreRevision {
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
-Copyright (C) 2008-2010 Foswiki Contributors. Foswiki Contributors
+Copyright (C) 2008-2017 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
@@ -178,23 +178,6 @@
%MAKETEXT{"You will receive an e-mail when your registration has been approved."}%
%TMPL:END%
%{==============================================================================}%
-%TMPL:DEF{"no_users_to_reset"}%
----+++ %MAKETEXT{"Password reset failed"}%
-%MAKETEXT{"No users to reset passwords for."}%
-%TMPL:END%
-%{==============================================================================}%
-%TMPL:DEF{"reset_bad"}%
----+++ %MAKETEXT{"Password reset failed."}%
-%PARAM1%
-%TMPL:END%
-%{==============================================================================}%
-%TMPL:DEF{"password_mismatch"}%
----+++ %MAKETEXT{"Passwords do not match"}%
-%MAKETEXT{"The two passwords you entered do not match."}%
-
-%MAKETEXT{"Please go back in your browser and try again."}%
-%TMPL:END%
-%{==============================================================================}%
%TMPL:DEF{"problem_adding"}%
---+++ %MAKETEXT{"Error registering user [_1]" args="%PARAM1%"}%
@@ -312,13 +295,6 @@
%MAKETEXT{"Return to [_1]." args="%SYSTEMWEB%.ChangeEmailAddress"}%
%TMPL:END%
%{==============================================================================}%
-%TMPL:DEF{"wrong_password"}%
----+++ %MAKETEXT{"Incorrect Password"}%
-%MAKETEXT{"The password you entered in the *old password* field is incorrect."}%
-
-%MAKETEXT{"Please go back in your browser and try again."}%
-%TMPL:END%
-%{==============================================================================}%
%TMPL:DEF{"bad_prefix"}%
---+++ %MAKETEXT{"Incorrect Prefix"}%
%MAKETEXT{"The prefix you entered for the deleted user is not valid as a topic name."}%
@@ -334,25 +310,6 @@
*[[%BASEWEB%.%BASETOPIC%][%MAKETEXT{"OK"}%]]*
%TMPL:END%
%{==============================================================================}%
-%TMPL:DEF{"password_not_changed"}%
----+++ %MAKETEXT{"Password could not be changed"}%
-
-%MAKETEXT{"Your system may not support changing passwords through Foswiki. Check with your Wiki administrator."}%
-
-*[[%TOPIC%][%MAKETEXT{"OK"}%]]*
-%TMPL:END%
-%{==============================================================================}%
-%TMPL:DEF{"password_changed"}%
----+++ %MAKETEXT{"Password changed successfully!"}%
-
-%IF{
- "{LoginManager} = 'Foswiki::LoginManager::ApacheLogin'"
- then="%MAKETEXT{"You may need to close your browser to make this change take effect."}%"
-}%
-
-*[[%USERSWEB%.%HOMETOPIC%][%MAKETEXT{"OK"}%]]*
-%TMPL:END%
-%{==============================================================================}%
%TMPL:DEF{"user_param_required"}%
---+++ %MAKETEXT{"User Account was not supplied"}%
%MAKETEXT{"Return to [_1] and supply a [[[_2]][WikiName]] or [[[_3]][username]]." args="[[%WEB%.%TOPIC%]], %SYSTEMWEB%.WikiName, %SYSTEMWEB%.UserName"}%

0 comments on commit 81de4e2

Please sign in to comment.