Gossamer Forum
Home : Products : Gossamer Mail : Discussion :

Allow Only a-zA-Z0-9 in usernames?

Quote Reply
Allow Only a-zA-Z0-9 in usernames?
Hi,

Can someone tell me how to only allow users to have a-zA-Z0-9 in usernames?

I can find the demographics table and see where to do it there with everything else on the signup page accept for the username. Then when looking at the webmail_users table with mysqlman I don't seem to have that option?

Can someone help me with this one!?

Cheers,
R.

Quote Reply
Re: Allow Only a-zA-Z0-9 in usernames? In reply to
Hi,

You would need to edit the users def file and look for the username column and change regex => '...' to whatever you need.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Allow Only a-zA-Z0-9 in usernames? In reply to
Hi Alex,

I have looked through all of the def files in the data/admin/def directory, and can't find a 'username' column mentioned anywhere in any of them? Including in the webmail_users.def?

The closest thing I've found is this:

'user' => {
'not_null' => '1',
'form_size' => '20',
'form_type' => 'TEXT',
'pos' => '2',
'binary' => '',
'size' => '255',
'form_display' => 'User Name',
'default' => '',
'type' => 'CHAR'
},

which if I'm right is the column that contains their 'full' user name including the @domainname.com after they've registered.

Is there another lot hiding somewhere that I can't find? Or is this the right one?

Cheers,
R.


Quote Reply
Re: Allow Only a-zA-Z0-9 in usernames? In reply to
Hello!

I had earlier already posted in GMail Forum sreaming at Alex by once again using the name of the column "user" which I found terrible. Before a year many users of Links SQL including me requested Alex to use the name Username and this was changed. It is a horror to have different.

Scott and Alex claimed (before half a year) that "We are trying to integrate the two". How? By desigining a converter script that understand both the columns. Or change the name later, obviously.

There is no collumn in the GMail as Username and its been a great fun to see here that even Alex got confused placing a wrong name of the column.

User data occurs only in two tables as you could see from MySQL Man and so called Username or user occurs only in user table. Most likely he means the User column which

http://www.Troubles.com/email/admin/admin.cgi?db=dgraph&do=editor_table_form

""" Below is all the columns in your dgraph table. By clicking on one of the column names, you can view more details as well as alter the column definition."""

Change Form Regex in there to I do not know what.
Quote Reply
Re: Allow Only a-zA-Z0-9 in usernames? In reply to
I'm thinking Alex meant the 'users' table. The regex field would probably be something like [a-zA-Z0-9]+ I tried doing this, but it wouldn't let me... said: "You can not alter column user, as table users still has references to it. Remove those references first." Probably can't change it after there's users added?

Adrian
Quote Reply
Re: Allow Only a-zA-Z0-9 in usernames? In reply to
Hmmmm...

Is there another way around it, like adding some code into the join script?

R.


Quote Reply
Re: Allow Only a-zA-Z0-9 in usernames? In reply to
You can hard code it into GMail::NoAuth::Join.pm until you get an answer. In the check_user sub (around line 221) add an if statement something like this:

In Reply To:
if ($cgi->{username} !~ /^[a-zA-Z0-9]+$/) {
$GMail::Template::TAGS{bad_username} = 1;
return $self->error('JOINERR_LOGIN_FMT', 'WARN', $cgi->{username});
}
right above the first if statement around line 240. That regex might need a little work, I am not very good with them yet. You might want to edit the template language for JOINERR_LOGIN_FMT to match the error a little better also. Make a back-up of the module before you make changes!

Regards,
Charlie


Quote Reply
Re: Allow Only a-zA-Z0-9 in usernames? In reply to
Sorry, I was in the wrong place, currently it is hard coded, and you must change it in the Auth module as piper describes.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Allow Only a-zA-Z0-9 in usernames? In reply to
Excellent! That worked perfectly Charlie, thanks for that.

Something that may want to be noted down and fixed is the language error/bug with the standard install:

%s is an invalid for for a username. Please choose another.

The first "for" should be format.

Cheers!!
Regan.


Quote Reply
Re: Allow Only a-zA-Z0-9 in usernames? In reply to
Hello Alex!

It would be so much nice if such an option is given in the admin like >>Database >> Demographics than allows such changes.

I have people inserting wild and funny characters from China!!!

Quote Reply
Re: [Chaz] Allow Only a-zA-Z0-9 in usernames? In reply to
Hi Charlie.

Fine it did work, and it's related to one of my recent query where i had wanted no underscores (as subdomain accounts are also given and the url has to comply with rfc 952) in username. Now i would also want a similar thing for password also with a change that the password length has to be 6 characters minimum (it can be more). What needs to be done....

Currently users can signup with just a . in password field.

Thnx

Anup