lock icon indicating copy to clipboard operation
lock copied to clipboard

Extra fields on signup

Open Maxim-Filimonov opened this issue 11 years ago • 9 comments

Hi, I know that current recommendation is to use custom UI for signup if any extra fields required. My problem with that approach is that addition of just one extra field requires us to code multiple custom different things:

  • Signup form,
  • Reset password (because it's usually part of signup form)
  • Backend /signup method
  • Validation using password rules specific by auth0 password policy (so that we don't get out of sync with login form)

And at the end we still have two different reset password forms which is really confusing for users. I propose to allow to add extra fields on signup form by using extension mechanism - fields are added by users of Auth0.lock not by Auth0 team. See example:

. showSignup({
 extra_fields: 
[
 { sel: 'input[name=fullname]', html: '<input name="fullname" type="text"></input>, field: "name" }
]
})

sel - selector to use to get value of the field html - the actual html used to render it. As it's just a string it's up to users use whatever they want - template, database base or just plain string like in example. field - the field to record information on user object. Then this line https://github.com/auth0/lock/blob/master/lib/mode-signup/index.js#L251 Needs to be changed to something like:

// set based on definition before
// extra_fields: [{name: 'Maxim Filimonov'}}
widget.$auth0.signup(xtend({
    connection: connection.name,
    username:   (options._isUsernameRequired()) ? username : email,
    email:      email,
    password:   password,
    auto_login: false,
    popup:      panel.options.popup,
  }, extra_fields)

I believe, that way it won't be required to change auth.js as it already merges options with everything else.

Just wondering what are you thoughts on that before making PR

Maxim-Filimonov avatar Mar 11 '15 23:03 Maxim-Filimonov

Ok just found a show stopper for this one. It looks like the auth.js is using dbconnections signup method instead of POST /users. Which i presume is done for security. However, the dbConnections signup method does not allow to pass any extra data when user signs up. Is it possible to change ?

Maxim-Filimonov avatar Mar 12 '15 01:03 Maxim-Filimonov

Just asking: why don't use auth0.js just for signup and keep using lock for signin, reset password, and keep all the form's validations for those fields?

If the real issue is having to code a sign in form, reset form , and validations... it's not actually an issue as I see it.

As a feature request it would require quite more work than presented. It's still valid, but I don't recall extra_fields being parsed as is as you present.

cristiandouce avatar Mar 12 '15 03:03 cristiandouce

@cristiandouce Cause auth.js doesn't allow us to signup with extra fields? :\ We are hacking its code now to make it use /users/create instead of dbconnections/signup as no one replied to us why this difference exists.

Maxim-Filimonov avatar Mar 12 '15 03:03 Maxim-Filimonov

Maxim is asking for a feature request. I've also made this same feature request here: https://ask.auth0.com/t/customize-sign-up-page/666

A lot of people seems to be interested in this subject. It'll be a GREAT option to have within the default modal login/reg box.

singularityjay avatar Mar 12 '15 19:03 singularityjay

any news whit this topic? i want to add just one extra field to the signup but i don't have any idea about how to do it

kiga01 avatar Oct 27 '15 19:10 kiga01

Perhaps file it at: http://feedback.auth0.com/

cancan101 avatar Nov 28 '15 20:11 cancan101

Hi, we are currently working on a new version of Lock that will allow you to add extra fields on the signup screen. Until it gets released you can code your own signup screen and use the Lock to sign in and reset password as @cristiandouce suggested. Thanks for the feedback and suggestions!

gnandretta avatar Nov 30 '15 14:11 gnandretta

Any news?

nemccarthy avatar Dec 04 '17 03:12 nemccarthy

@nemccarthy this is already supported OOTB https://auth0.com/docs/libraries/lock/v10/configuration#additionalsignupfields-array-

luisrudge avatar Dec 04 '17 13:12 luisrudge