Re: [web2py] How to call user/register with pre-defined fields (name, email)?
For the record, here's how I was able to implement an "by invitation only" registration form. Assuming that the user received an email with a link of form http://.../default/user/register?token=sfaasdfasfa, and assuming I have defined a db table 'registrant' associating a token with a name and email, here's the bare-bones functionality, where the user sees a registration form with his name and email pre-filled out (and not editable), and he can pick a password. Note that to get web2py's Auth() class to do it's registration things (use all the settings to encrypt passwords, insert new user in database, send email verification email, etc), this has to be done at http:///user/register def user(): if request.args(0)=='register': form=auth.register() registrant = db( db.registrant.token == request.vars.token ).select().first() form.element(_name='first_name').update(_value=registrant.first_name) form.element(_name='last_name').update(_value=registrant.last_name) form.element(_name='email').update(_value=registrant.email) form.element(_name='first_name')['_readonly']=True form.element(_name='last_name')['_readonly']=True form.element(_name='email')['_readonly']=True return dict(form=form) Quite short and sweet, once you figure it out :) Thanks for everybody's help!!! L.
Re: [web2py] How to call user/register with pre-defined fields (name, email)?
That's a great idea, David! I think I need to know, then: - how to programmatically create registered users - how to programmatically send them the 'reset password' link. Ideally, the person that can invite users will have a simple webpage form where they can input names and email addresses, and upon form submission the accounts get created and invite-as-reset-password emails get sent out. Thanks for the idea! I'll try to figure it out - but if anyone already knows how to do the above steps (second one is probably easy), I'd really appreciate the time-saving help!!! Luis.
Re: [web2py] How to call user/register with pre-defined fields (name, email)?
Thanks, pbreit, for the link! Long thread!!! I read it all, but am still unclear how to force registration with a pre-defined name and email (I'll have DB entries such that each unique invite token is associated with a pre-defined name and email). I was hoping to do something like this: def user(): if request.args(0)=='invite': # person has clicked on their invite which takes them to default/user/invite?token=aalsfjlkajflasjflkasjdfl # use the token to look up name and email invite_info = db( db.invite.token == request.vars.token ).select().first() form = auth() # ??? how to make it a registration form ??? # ? Somehow, insert predefined name and email into registration form, #and make them READONLY ? form.first_name = invite_info.first_name ? how to make the field READONLY ? (I think I should change the db.auth definition in db.py !) ? form.last_name = ... ? form.email = return dict(form=form) However (aside from not knowing how to set the fields), this does not work: - a simple test case with dummy code returns 404 Not Found unless I comment out the call to form=auth() the test case: if request.args(0)=='invite': form = auth() response.view = 'default/invite.html' return dict(msg='hello', magic='banana', results='tada') (commenting out form=auth() makes it fine, otherwise 404 Not Found) I suppose auth() was not designed to be manipulated this way? Ultimately, what I don't know how to do is to create a registration form with predefined name and email, so the user just has to pick a password. Thanks!!! Luis.
Re: [web2py] How to call user/register with pre-defined fields (name, email)?
Check this recent thread: https://groups.google.com/d/topic/web2py/QZ11R6eYQdM/discussion
Re: [web2py] How to call user/register with pre-defined fields (name, email)?
You can easily do this. Just think its the reset password function with a twist. On Jul 4, 2011 8:38 PM, "Luis Goncalves" wrote: > Hello! > > The website I am developing will be "invitation only": > > - a user gets an email invitation to register with a link to the site (with > an identifying token in the link) > > - the link takes the user to the website, where he can register > > - to register, he need only define the password, since the person's name and > email is already known (login will be email/password) > (a confirmation email is still sent, before they can log in) > > ? How do I call user/register with the person's name and email already > filled out, and non-modifiable, > so that they only need to define a password ? > > Thanks!!! > Luis.
Re: [web2py] How to call user/register with pre-defined fields (name, email)?
This section of the book could help : http://www.web2py.com/book/default/chapter/08?search=setting#Settings-and-Messages Richard On Mon, Jul 4, 2011 at 8:37 PM, Luis Goncalves wrote: > Hello! > > The website I am developing will be "invitation only": > > - a user gets an email invitation to register with a link to the site (with > an identifying token in the link) > > - the link takes the user to the website, where he can register > > - to register, he need only define the password, since the person's name > and email is already known (login will be email/password) > (a confirmation email is still sent, before they can log in) > > ? How do I call user/register with the person's name and email already > filled out, and non-modifiable, >so that they only need to define a password ? > > Thanks!!! > Luis. >
[web2py] How to call user/register with pre-defined fields (name, email)?
Hello! The website I am developing will be "invitation only": - a user gets an email invitation to register with a link to the site (with an identifying token in the link) - the link takes the user to the website, where he can register - to register, he need only define the password, since the person's name and email is already known (login will be email/password) (a confirmation email is still sent, before they can log in) ? How do I call user/register with the person's name and email already filled out, and non-modifiable, so that they only need to define a password ? Thanks!!! Luis.