[ic] indirect login with unique column

Bill Carr bill at worldwideimpact.com
Tue Dec 2 21:09:28 EST 2003

----- Original Message ----- 
From: "Mike Heins" <mike at perusion.com>
To: <interchange-users at icdevgroup.org>
Sent: Tuesday, December 02, 2003 7:20 PM
Subject: Re: [ic] indirect login with unique column

> Quoting Bill Carr (bill at worldwideimpact.com):
> > IC 4.9.9, MySQL 4.0.16
> >
> > I have indirect_login set to email in my UserDB config. I also have a
> > UNIQUE INDEX on my email column in the userdb table. This seems like a
> > reasonable thing to do.
> >
> > Creating a new account was not working because of the UNIQUE INDEX. It
> > worked once but would not work after that because the insert statement
> > was failing with out including the 'email' value.
> >
> > I have made some hacks to UserDB.pm to fix this for myself. I will post
> > the changes if anyone thinks they would be of value. Someone please tell
> > me if I am just missing something here.
> I don't understand why you think there are two INSERT operations.
> If you are telling me that a subsequent UPDATE fails because the email
> column is not included in the list of fields updated, I would say that
> is a problem in MySQL. I see no reason that you have to include a field
> on every update.
In Vend::UserDB::new_account there is this:

  my $pass = $udb->set_field(
  die ::errmsg("Database access error.") . "\n" unless defined $pass;

  if($foreign) { ...

If you somehow have row with a value of '' in the email column the above
dies. MySQL complains with error 1062 duplicate key '' for key 2. Now I
realize that there should not be a value of '' in the email column but some
how it happened. When it did no one else could create an account and
therefore no new customers could buy anything a this particular store.

I rewrote the above as follows and it solved my problem.
  my $fary;
  my $vary;
  push @$fary, $self->{LOCATION}{PASSWORD};
  push @$vary, $pw;
  if($foreign) {
    push @$fary,$foreign;
    push @$vary,$self->{PASSED_USERNAME};

  my $pass = $udb->set_slice(

Please tell me what you think. I can take it like a man!

Bill Carr

More information about the interchange-users mailing list