Skip to content

Commit

Permalink
Item11501: Better user response
Browse files Browse the repository at this point in the history
Convert the Error::Simple into an oops message.

git-svn-id: http://svn.foswiki.org/branches/Release01x01@13909 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Feb 4, 2012
1 parent 79ebf98 commit c1825ec
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
17 changes: 14 additions & 3 deletions core/lib/Foswiki/UI/Register.pm
Original file line number Diff line number Diff line change
Expand Up @@ -694,14 +694,13 @@ sub addUserToGroup {
#next if ( $u eq '' );
$u = '' if ( $u eq '<none>' );

$u = $session->{users}->validateRegistrationField( 'username', $u );

next
if ( Foswiki::Func::isGroup($groupName)
&& Foswiki::Func::isGroupMember( $groupName, $u, { expand => 0 } )
);

try {
$u = $session->{users}->validateRegistrationField( 'username', $u );
Foswiki::Func::addUserToGroup( $u, $groupName, $create );
push( @succeeded, $u );
}
Expand Down Expand Up @@ -1561,7 +1560,19 @@ sub _getDataFromQuery {
# deal with multivalue fields like checkboxen
my $value = join( ',', @values );

$data->{$name} = $users->validateRegistrationField( $name, $value );
try {
$data->{$name} = $users->validateRegistrationField( $name, $value );
}
catch Error::Simple with {
my $e = shift;
throw Foswiki::OopsException(
'attention',
#web => $data->{webName},
#topic => $session->{topicName},
def => 'invalid_field',
params => [ $name ]
);
};
push(
@{ $data->{form} },
{
Expand Down
6 changes: 6 additions & 0 deletions core/templates/messages.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,12 @@
---+++ %MAKETEXT{"Missing Fields"}%
=<font color="red">**</font>= %PARAM1% %MAKETEXT{"fields are required."}%

%MAKETEXT{"Please go back in your browser and try again."}%
%TMPL:END%
%TMPL:DEF{"invalid_field"}%
---+++ %MAKETEXT{"Invalid Input"}%
=<font color="red">**</font>= %MAKETEXT{"The value supplied for =[_1]= has been rejected." args="%PARAM1%"}%

%MAKETEXT{"Please go back in your browser and try again."}%
%TMPL:END%
%TMPL:DEF{"password_mismatch"}%
Expand Down

0 comments on commit c1825ec

Please sign in to comment.