[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] Email address as Unique ID? Having a problem
At 10:54 PM 10/21/2002 -0700, you wrote:
> > We need to use email address as username and be sure it is
> > unique. I saw this discussion come up on the list recently
> > about how you can enforce this column to be unique by
> > editing the profiles.order file. We added the following
> > bit of code to IC and it doesn't seem to work for us:
> >
> > email=unique userdb: E-Mail address isn't unique
>
>I've been dealing with the same problem. I tried doing exactly what you
>did and I had no luck.
AFAIK the unique order check only works on the key of a table (which would
be username for the userdb). To get it to work on a non-key field, you
might have to override and modify the order check.
It so happens that I had to solve this problem back when I was working on a
4.6.5 catalog, so I wrote a custom order check to do it. Here it is; no
warranty that it will work in the 4.8 branch or that it is particularly
efficient. You would want to include this into interchange.cfg or just
paste it directly in that file.
- Ed L.
GlobalSub <<EOF
sub set_up_extra_check {
BEGIN {
package Vend::Order;
sub _unique {
my ($valref, $var, $val) = @_;
my (@rec, $key, $field_val, $db);
$db = Vend::Data::database_exists_ref('userdb');
$db = $db->ref();
$field_val = $db->field_accessor($var);
while (@rec = $db->each_record()) {
$key = shift @rec;
if ($field_val->($key) eq $val) {
return (undef, $var, "not unique")
unless $key eq
$Vend::Session->{username};
}
}
return (1, $var, '');
}
}
}
EOF
===============================================================
New Media E.M.S. Technology Solutions for Business
463 Main St., Suite D eCommerce | Consulting | Hosting
Placerville, CA 95667 edl@newmediaems.com
(530) 622-9421 http://www.newmediaems.com
(866) 519-4680 Toll-Free (530) 622-9426 Fax
===============================================================