[ic] mv_username, username

Stefan Hornburg (Racke) racke at linuxia.de
Tue Sep 28 19:24:37 UTC 2010


On 09/28/2010 08:57 PM, Steve Graham wrote:
> Hello,
>
> I am trying to get the value of a non-matching/failed username/password
> login attempt from the standard store login page:
>
> I have tried
> [cgi username]
> [cgi mv_username]
> [scratch mv_username]
> [scratch username]
>
> and they all return empty.
>
> I need to test the username against another database and pop a message
> if it is found.
>
> Any suggestions?

I suppose the mv_username CGI variable is removed when the check fails.

For custom login procedures I suggest using an ActionMap. Here an example:

ActionMap login <<EOA
sub {
	$Tag->perl({tables => 'users'});
	my $failedmsg = "Die Kombination Ihrer Zugangsdaten ist nicht korrekt.";

	$CGI->{mv_nextpage} = 'login';

	if ($Session->{logged_in}) {
		$Tag->warnings({message => 'You are already logged in as user %s',
			param => $Session->{username}});
		return 1;
	}

	if ($CGI->{register}) {
		$CGI->{mv_nextpage} = 'register';
		return 1;
	}

	# look for user submission
	if (exists $CGI->{mv_username}) {
		my ($ret, $set);
		$Tag->perl({tables => 'users'});
			

		if ($CGI->{mv_username} =~ /\@/) {
			# check for case ...

			$set = $Db{users}->query(q{select email, inactive from users where email ilike '%s'}, $CGI->{mv_username});

			if (@$set && $set->[0]->[1] eq 'Y'){
				$Tag->error({name => 'login', set => $failedmsg});
				return 1;
			}
			
			if (@$set && $set->[0]->[0]) {
				Log("Using $set->[0]->[0] for login instead of $CGI->{mv_username}.");
				$CGI->{mv_username} = $set->[0]->[0];
			}

			# login with email address
			$ret = $Tag->userdb({function => 'login'});
		}
		else {
			# login with username
			$set = $Db{users}->query(q{select inactive from users where username='%s'}, $CGI->{mv_username});
			if (@$set && $set->[0]->[0] eq 'Y'){
				$Tag->error({name => 'login', set => $failedmsg});
				return 1;
			}

			$ret = $Tag->userdb({function => 'login',
				indirect_login => 'username'});
		}
		if ($ret) {
			# load location from billing address
			$Tag->address('load', 'billing');
			$Values->{shippingcountry} = $Tag->address('get', 'shipping', 'country');
	
			delete $Scratch->{login_hint};

			if ($Scratch->{login_target}) {
				$CGI->{mv_nextpage} = delete $Scratch->{login_target};
			}
			elsif ($Scratch->{login_bounce}) {
				$Tag->deliver({location => $Tag->area(delete $Scratch->{login_bounce}), status => '302 move temporarily'});
				return;
			}
			else {
				$Tag->deliver({location => $Tag->area('index'), status => '302 move temporarily'});
				return;
			}
		}
		else {
			$Tag->error({name => 'login', set => $failedmsg});
		}
	}

	return 1;
}
EOA

Regards
	Racke


-- 
LinuXia Systems => http://www.linuxia.de/
Expert Interchange Consulting and System Administration
ICDEVGROUP => http://www.icdevgroup.org/
Interchange Development Team




More information about the interchange-users mailing list