Forums / Developer / user registration without username

user registration without username

Author Message

Jacek S

Monday 28 April 2008 1:19:02 pm

I want to provide users user registration form only with e-mail and password. I want to get rid of username and make users to use only emails as theirs logins.
But, when i remove this field from register.pl user doesn't get registered despite that no error message is shown.

How could I achieve this - registering without providing username?

Piotrek Karaƛ

Tuesday 29 April 2008 7:23:53 am

Hi Jacek,

1) The fact that you modify the presentation layer of the application will not always have any effect on the way the application logic works. In fact, it should not, otherwise it's a security bug.

2) What you have done caused eZ Publish to skip the login attribute and accept the attribute, and this is a bug, especially when it comes user datatype. It's the problem of "weak attribute validation", I've already submitted it as a bug. Meanwhile, the reason this particular attribute behaved the way it did was:

function validateObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
    {
        if ( $http->hasPostVariable( $base . "_data_user_login_" . $contentObjectAttribute->attribute( "id" ) ) )
        { (...) }
        return eZInputValidator::STATE_ACCEPTED;
    }

As you can see, it only validates the login part of user datatype, otherwise accepting it.

3) To answer your question - I'm not sure if it is possible to skip this part. I mean this may be possible if you modify the user account datatype or write your own, but the value might be used internally somewhere, so I would carefully test it first.

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Bruce Morrison

Tuesday 29 April 2008 4:00:13 pm

Hi Jacek

I'd think the easiest way to get around this issue is to modify the override the ezuser.tpl edit template so that the username input is hidden. Set the value of the input to a random unique username, you might need a custom template operator for this. Also you'll want to modify all the ezuser templates as well as any other that reference the username (activation emails etc).

All a bit smoke n' mirrors but it should do the job.

cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Jacek S

Tuesday 06 May 2008 11:53:51 am

Thank you both for help.
I resolved this problem slightly other way - my code is just filtering user email with some regexp(removing all non alphanumerics signs) and putting it in username.

eZ debug

Timing: Jan 18 2025 19:15:33
Script start
Timing: Jan 18 2025 19:15:33
Module start 'content'
Timing: Jan 18 2025 19:15:33
Module end 'content'
Timing: Jan 18 2025 19:15:33
Script end

Main resources:

Total runtime0.0175 sec
Peak memory usage2,048.0000 KB
Database Queries4

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0059 588.8516180.8281
Module start 'content' 0.00590.0059 769.679798.0078
Module end 'content' 0.01180.0056 867.687574.7031
Script end 0.0174  942.3906 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002413.8460120.0002
Check MTime0.00126.6169120.0001
Mysql Total
Database connection0.00084.676810.0008
Mysqli_queries0.002212.714740.0006
Looping result0.00000.086120.0000
Template Total0.005229.610.0052
Template load0.00095.030710.0009
Template processing0.004324.492110.0043
Override
Cache load0.00063.495010.0006
General
dbfile0.00063.3638100.0001
String conversion0.00000.028730.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs