[ic] indirect login with unique column
Mike Heins
mike at perusion.com
Tue Dec 2 22:34:24 EST 2003
Quoting Bill Carr (bill at worldwideimpact.com):
> ----- 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(
> $self->{USERNAME},
> $self->{LOCATION}{PASSWORD},
> $pw,
> );
> 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(
> $self->{USERNAME},
> $fary,
> $vary,
> );
>
>
> Please tell me what you think. I can take it like a man!
I think it is fine. The case seems pretty borderline, but I guess
it could happen; it did. 8-)
I think that the $pass = ... is wrong, though. It will actually
return the username. Perhaps the value is not used after that;
but it would make sense to name it something else.
--
Mike Heins
Perusion -- Expert Interchange Consulting http://www.perusion.com/
phone +1.765.647.1295 <mike at perusion.com>
Some people have twenty years of experience, some people have
one year of experience twenty times over. -- Anonymous
More information about the interchange-users
mailing list