My mistake, should have been
form.errors.update({'email':'not allowed'})
By adding the error message it prevent the user from registering
(because he does not have a valid token).
You do not need to pay me for help in this list but I will not refuse
a donation. ;-)
Massimo
On Jun 20, 8:16 pm, Dwayne <[email protected]> wrote:
> Dear Massimo,
>
> Thank you very much. I'll send you the 30 dollars if it works :)
>
> I have a problem. I cannot compile :
>
> auth.settings.register_onvalidation.append(lambda form:
> db.invitation(token=form.vars.email) or
> form.errors.update({'email','not allowed'}))
>
> Why do I need : form.errors.update({'email','not allowed'}) ?
>
> Thank you very much !
>
> Dwayne
>
> On 20 juin, 02:09, Massimo Di Pierro <[email protected]>
> wrote:
>
>
>
>
>
>
>
> > OK try this:
>
> > definvitation():
> > form = SQLFORM.factory(Field('email',requires=IS_EMAIL()))
> > if form.accepts(request):
> > db.invitation.insert(token = form.vars.email)
> > MESSAGE = 'click %s to register'
> > url = URL('user/register',host=request.env.http_host)
> > mail.send(to=form.vars.email, message=MESSAGE % url)
> > redirect('success_invitation'))
> > return dict(message=('Invitationto be sent'),
> > form=form,address=form.vars.email)
>
> > auth.settings.register_onvalidation.append(lambda form:
> > db.invitation(token=form.vars.email) or
> > form.errors.update({'email','not allowed'}))
> > auth.settings.register_onaccept.append(lambda form:
> > db(db.invitation.token==form.vars.email).delete())
>
> > On Jun 4, 9:28 am, Dwayne Blind <[email protected]> wrote:
>
> > > Can somebody please help me ? I would really want this to work.
>
> > > I customized db.auth_user, as described in the book, to add a 'token'
> > > field. I just added : Field('token', writable=False, readable=False,
> > > default='').
>
> > > Then, in the controllers, I modified default.py :
>
> > > def user():
> > > db.auth_user.insert(token=request.args(1))
> > > return dict(form=auth())
>
> > > Then in the models, I modified db.py :
>
> > > def my_auth_processing(form):
> > > if db(db.auth_user.token!='')
> > > (db.invitation.token==db.auth_user.token):
> > > return True
> > > else :
> > > return False
>
> > > auth.settings.register_onvalidation.append(lambda form:
> > > my_auth_processing(form))
>
> > > But unfortunately no one is prevented from registering... So this does
> > > not work.
>
> > > Dwayne
>
> > > On 2 juin, 02:31, pbreit <[email protected]> wrote:
>
> > > > Oops. For registration, you use
> > > > this:http://web2py.com/book/default/chapter/08?search=register_onvalidation-Masquer
> > > > le texte des messages précédents -
>
> > - Afficher le texte des messages précédents -