From 0c69c93f4122b5df5ab1a04a20b98c25c9f825d9 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 14 Feb 2006 06:50:14 +0000 Subject: [PATCH] forward port of becoming illegal userId bugfix --- lib/WebGUI/Operation/User.pm | 1 + lib/WebGUI/User.pm | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/WebGUI/Operation/User.pm b/lib/WebGUI/Operation/User.pm index a3f2dd6f3..69e5caa6a 100644 --- a/lib/WebGUI/Operation/User.pm +++ b/lib/WebGUI/Operation/User.pm @@ -222,6 +222,7 @@ Allows an administrator to assume another user. sub www_becomeUser { my $session = shift; return $session->privilege->adminOnly() unless ($session->user->isInGroup(3)); + return unless WebGUI::User->validUserId($session, $session->form->process("uid")); $session->user({userId=>$session->form->process("uid")}); $session->var->end($session->var->get("sessionId")); $session->var->start($session->form->process("uid"),$session->getId); diff --git a/lib/WebGUI/User.pm b/lib/WebGUI/User.pm index e05acf491..c8cb3f282 100644 --- a/lib/WebGUI/User.pm +++ b/lib/WebGUI/User.pm @@ -45,6 +45,8 @@ This package provides an object-oriented way of managing WebGUI users as well as $u->deleteFromGroups(\@arr); $u->delete; + WebGUI::User->validUserId($session, $userId); + =head1 METHODS These methods are available from this class: @@ -654,4 +656,18 @@ sub userId { return $_[0]->{_userId}; } +#------------------------------------------------------------------- + +=head2 validUserId ( userId ) + +Returns true if the userId exists in the users table. + +=cut + +sub validUserId { + my ($class, $session, $userId) = @_; + my $sth = $session->db->read('select userId from users where userId='.$session->db->quote($userId)); + return ($sth->rows == 1); +} + 1;