[web2py] Re: redirect after registration issue

2013-06-07 Thread lesssugar
Yep. This was embarrassingly simple. Thanks for help and patience. On Friday, June 7, 2013 9:34:28 PM UTC+2, Anthony wrote: > > def register(): > if not request.args(0) in [list, of, valid, groups]: > [redirect somewhere or return an error message] > [rest of your registration cod

[web2py] Re: redirect after registration issue

2013-06-07 Thread Anthony
def register(): if not request.args(0) in [list, of, valid, groups]: [redirect somewhere or return an error message] [rest of your registration code] Anthony On Friday, June 7, 2013 1:52:57 PM UTC-4, lesssugar wrote: > > Instead, check it before you even call auth.register(). >>

[web2py] Re: redirect after registration issue

2013-06-07 Thread lesssugar
> > Instead, check it before you even call auth.register(). > Not sure how to achieve this. It's goes the following way now: 1. The registration view renders. request.args(0) is checked (group1 or group2) and respective form generates. At this point the URL argument is OK (as user came to regi

[web2py] Re: redirect after registration issue

2013-06-07 Thread Anthony
Don't check the validity of request.args(0) in the onaccept callback -- that's too late. Instead, check it before you even call auth.register(). Anthony On Friday, June 7, 2013 9:58:09 AM UTC-4, lesssugar wrote: > > It's pretty straightforward - there are 2 registration links in the menu > and

[web2py] Re: redirect after registration issue

2013-06-07 Thread lesssugar
It's pretty straightforward - there are 2 registration links in the menu and each of them links to default/register/[group_type]. Then, in the view, request.args(0) value is being checked to generate respective form. Guess, I'll go for the request.args(0) limitation, as you wrote. By the way, c

[web2py] Re: redirect after registration issue

2013-06-07 Thread Anthony
How do users get to their respective registration URLs to begin with? If they are sent a link via email, you could use a digital signature. If they are allowed to choose the group themselves by making a selection, then your cu

[web2py] Re: redirect after registration issue

2013-06-07 Thread lesssugar
That's my concern also. I simply would like to make a transparent registration for 2 groups separately. In order to do so I have two different forms generating depending on URL argument: default/register/[group1] or [group2]. Checking request.args(0) on "onaccept" seemed obvious but it needs im

[web2py] Re: redirect after registration issue

2013-06-06 Thread Anthony
Yes, you should not call .process() after calling auth.register() because the second time through .process() it will fail (the _formkey token is only good for one process -- so it fails on the second). Using an onaccept callback is the way to go. However, it appears you are allowing your users

[web2py] Re: redirect after registration issue

2013-06-06 Thread lesssugar
OK, I figured out something like this and it works (let me know if it's not correct in any way): In db.py model: auth.settings.create_user_groups = False and then def add_group(form): group_id = auth.id_group(role=request.args(0)) auth.add_membership(group_id, form.vars.id) auth.sett

[web2py] Re: redirect after registration issue

2013-06-06 Thread lesssugar
Sorry, there is one more "but". After renaming the form all goes well, except that this piece of code if register_form_s.accepts(request.vars, formname='register'): auth.add_membership(group_id=1, user_id=register_form_s.vars.id) no longer adds the right membership to user. It gives them the

[web2py] Re: redirect after registration issue

2013-06-06 Thread lesssugar
Yes, renaming the form to "register" did the trick. Thank you. On Friday, June 7, 2013 1:11:23 AM UTC+2, Anthony wrote: > > I think the form processing within the auth.register() function is > probably failing because you have renamed the form to 's_registration', and > it is expecting a form na

[web2py] Re: redirect after registration issue

2013-06-06 Thread Anthony
I think the form processing within the auth.register() function is probably failing because you have renamed the form to 's_registration', and it is expecting a form named 'register' (it uses the formname to check the _formkey value in the session). If the form doesn't get accepted, it doesn't

[web2py] Re: redirect after registration issue

2013-06-06 Thread lesssugar
Right, thanks. But what about the "next" attribute? What might be the reason of the arument not working? On Friday, June 7, 2013 12:53:35 AM UTC+2, Anthony wrote: > > auth.register() automatically processes the form, so you should not > subsequently call request_form.process(). > > Anthony > > O

[web2py] Re: redirect after registration issue

2013-06-06 Thread Anthony
auth.register() automatically processes the form, so you should not subsequently call request_form.process(). Anthony On Thursday, June 6, 2013 6:21:52 PM UTC-4, lesssugar wrote: > > After user registers, I would like to redirect them to a different URL, > let's say default/index. > > Auto-logi