[support] Forcing username pattern

Metzler, David metzlerd at evergreen.edu
Thu Mar 13 15:40:08 UTC 2008


Hi Larry, 

Don't know how relevant this is, but we're in the process of writing
some code around controlling user-names here as well for another SSO
module (CAS).  So my head is really around this problem right now.  

For SSO solutions, we're implementing a username transformation hook in
the sso module, which I know will not work for you (at least I don't
think).  But when using SSO solutions such as opened or cas are used,
I've always been bothered that we create a user account before it's been
approved in the registration process.

This is similar to the code in the LDAP module, but we're using a hook
based approach to make it easier for other module developers to tie
into.  Given that, I don't think LDAP or CAS has the right solution for
you.  

Here's an idea for a module pattern that might work: 

1. User the form_alter hook to change the field '#type' of the username
to 'value' for the user_name form on a module.  

2. Use the profile module to add the extra fields to the form. 

3. In the  form-alter hook, add form level validation fields to make
sure that the generated username is unique, or guarantee uniqueness via
some algorithm.  

The implementation is left as an exercise for the user :). Does that
approach make sense? 

Dave






 

-----Original Message-----
From: support-bounces at drupal.org [mailto:support-bounces at drupal.org] On
Behalf Of Larry Garfield
Sent: Thursday, March 13, 2008 2:00 AM
To: support at drupal.org
Subject: [support] Forcing username pattern

Hi folks.  I've a question that's come up on a number of my sites now.
I'd 
like to be able to disallow users from selecting their own usernames,
ever, 
even on signup.  Instead, I want to expose various profile fields (or
custom 
fields via form-alter if necessary) and then base the username off of
that.  
E.g., first intial and last name, all lower-case.  Does anyone know of
an 
existing module or mechanism for that, or a common pattern that could be

turned into a module?

-- 
Larry Garfield			AIM: LOLG42
larry at garfieldtech.com		ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an
idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the
possession 
of every one, and the receiver cannot dispossess himself of it."  --
Thomas 
Jefferson
-- 
[ Drupal support list | http://lists.drupal.org/ ]


More information about the support mailing list