On Sep 28, 2006, at 10:51 AM, Stefan Hornburg wrote:
I have taken another look at this it it just seems impossible to use an AUTO_INCREMENT field in the userdb for the username and a foreign email field. Maybe I just do things weird but to me this seems like a common setup we should support. Now I'm a MySQL guy so I don't know how this stuff goes down using other DBs.Bill Carr wrote:I can not figure out how to use indirect_login and an AUTO_INCREMENT username column with my UserDB to create a new account.mysql> SHOW CREATE TABLE userdb; CREATE TABLE `userdb` ( `username` int(11) NOT NULL auto_increment, `email` varchar(128) NOT NULL default '', `password` varchar(20) NOT NULL default '', `acl` text, ... I've tried all kinds of combinations like below. UserDB default <<EOD { userminlen => 1, passminlen => 1, crypt => 0, time_field => 'mod_time', database => 'userdb', indirect_login => 'email', logfile => 'userdb.log', sql_counter => 'userdb:username', assign_username => 1 } I always end up with two records in my UserDB like so:mysql> SELECT username,email,password FROM userdb ORDER BY username DESC LIMIT 2;+----------+--------------------------+----------+ | username | email | password | +----------+--------------------------+----------+ | 1724 | | password | | 1723 | suppressed | | +----------+--------------------------+----------+It seems like I could make sure I have a numeric counter file with a value at least as high as MAX(username) but that seems like something that should be able to be avoided. Is there a way to use an AUTO_INCREMENT username column with indirect_login in Interchange?The problem is that IC creates first a record with just username/ password and fills in the details later. Personally, I thinkaccounts should created in an atomic operation.
First patch Interpolate.pm to make tag_counter work with UserDB sql_counter userdb:username for MySQL:
--- /root/interchange-5.4.1/lib/Vend/Interpolate.pm 2005-12-23 09:59:44.000000000 -0500
+++ Vend/Interpolate.pm 2006-09-28 13:41:54.000000000 -0400
@@ -2139,9 +2139,9 @@
);
}
elsif($dsn =~ /^dbi:mysql:/i) {
- $seq ||= $tab;
- $dbh->do("INSERT INTO $seq VALUES
(0)") or die $diemsg;
- my $sth = $dbh->prepare("select
LAST_INSERT_ID()")
+ $seq = qq{($seq)} if $seq;
+ $dbh->do("INSERT INTO $tab $seq VALUES
(0)") or die $diemsg;
+ my $sth = $dbh->prepare("select
LAST_INSERT_ID()")
or die $diemsg;
$sth->execute
() or die
$diemsg;
($val) = $sth->fetchrow_array;
Now after we get this going we are able to get a username using
sql_counter. However, because we now have a new record in the userdb
it breaks the existing account check in UserDB::new_account. The
following modification gets us by that.
--- /root/interchange-5.4.1/lib/Vend/UserDB.pm 2005-11-09 04:04:18.000000000 -0500 +++ /usr/lib/interchange/Vend/UserDB.pm 2006-10-04 11:00:26.000000000 -0400
@@ -1556,8 +1556,11 @@
};
}
- if ($udb->record_exists($self->{USERNAME})) {
- die errmsg("Username already exists.") . "\n";
+ my $record_exists = $udb->record_exists($self->
{USERNAME});
+ if ($self->{OPTIONS}{sql_counter}) {
+ die errmsg("Could not create Username.") . "\n"
unless $record_exists;
+ } else {
+ die errmsg("Username already exists.") . "\n" if
$record_exists;
}
if($foreign) {
Bill Carr
Bottlenose - Wine & Spirits eBusiness Specialists
(877) 857-6700
_______________________________________________
interchange-users mailing list
suppressed
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.