[ic] Use E-Mail Address Instead Of Username For Login

Ron Phipps interchange-users@icdevgroup.org
Thu Oct 17 15:47:01 2002


> From: Mike Heins
> 
> Quoting Mike Heins (mike@perusion.com):
> > Quoting Matthew Villa (matt@1percent.com):
> > > I want the customer to login by specifying their e-mail address
not
> > > their username. I basically need a login screen similar to NetFlix
and
> > > Amazon.
> > >
> > > I need to modify the registration form so they don't specify their
> > > username. Instead, they specify their e-mail address and their
> password
> > > on the registration form.
> > >
> > > I am assuming that I will need to have the system to assign a user
id
> to
> > > their account automatically so it's used as a unique identifier
for
> > > their account.
> > >
> > > If anyone can help me out that would be wonderful. Thanks in
advance.
> >
> > Can't help you with 4.8 other than point you to search for "unique"
> > in recent list postings at Google.
> >
> > With 4.9, there is a new indirect login capability. It automatically
> > checks that for uniqueness, and allows you to assign a customer
number
> > automatically. To use it, you need in catalog.cfg:
> >
> > UserDB    default    indirect_login  email
> > UserDB    default    assign_username 1
> > UserDB    default    sql_counter     userdb:custno
> >
> > You can omit the sql_counter parameter if you don't want to use
> > a sequence in your database to create the user number. Otherwise,
> > create a sequence as described in the sql_counter docs (4.9) for
> > the counter tag.
> 
> Looking at this, it is unclear what I said. The capability works
> fine if you just put:
> 
>  UserDB    default    indirect_login  email
>  UserDB    default    assign_username 1
> 

I just verified this works as you described, looks good :)

> It then just uses the normal "etc/username.counter" file and
> starts the numbers at U00001. You don't even need sql_counter
> to do integer numbers if you initialize etc/username.counter
> with an integer.

If you would like to use an integer you will need to initialize
etc/username.counter to an integer greater then 9, otherwise the
creation of the first 10 users fail since it expects at least a 2
character username.

Another issue that I will resolve soon is if you do the indirect login
and then try to change your email address in the account maintenance
screen to an email address that already exists it dies silently.  If you
change your email to an address that does not exist it will save as
expected.

The right way to probably fix this is in the userdb save code check if
indirect login is being used and if so then verify that the value being
saved is unique otherwise throw an error that the value is not unique.

Thanks for the code Mike, this is a great feature!
-Ron

> Also, to forestall what might be common questions -- no changes
> to login forms are needed. You still use mv_username, etc.
> 
> As I think about it, I think I did this on a 4.8 catalog with:
> 
> [if type=data term="userdb::username::[cgi mv_username]"]
> 	# do nothing, they used their customer number
> [else]
>     [tmp indirect][data table=userdb column=username foreign=email
> key="[cgi mv_username]"][/tmp]
>     [if scratch indirect]
>         [calc]
>             $CGI->{mv_username} = $Scratch->{indirect};
>             return;
>         [/calc]
>     [/if]
> [/else]
> [/if]
> [if type=explicit compare="[userdb login]"]
> mv_nextpage=[either][cgi mv_successpage][or][cgi mv_nextpage][/either]
> [else]
> mv_nextpage=[either][cgi mv_failpage][or][cgi mv_nextpage][/either]
> [/else]
> [/if]
> 
> In that case, you of course have to run a unique check on the email
> address before login. But you can still use "assign_username" to
> assign the customer number.
> 
> --
> Mike Heins
> Perusion -- Expert Interchange Consulting    http://www.perusion.com/
> phone +1.513.523.7621      <mike@perusion.com>
> 
> Unix version of an Outlook-style virus:
> It works on the honor system. Please forward this message to everyone
> you know, and delete a bunch of your files at random.
> _______________________________________________
> interchange-users mailing list
> interchange-users@icdevgroup.org
> http://www.icdevgroup.org/mailman/listinfo/interchange-users