It is not working because you are settings auth.settings.login_next
within the scope of one http request, after redirect you have another
http request and everything is reset. Only session variables persist
from one http request to another.

You can simplify your code and do what you ask in this way:

def index():
    meetingparm = (request.env.http_host or '').split('.')[0]
    meeting = db(db.meeting.link==meetingparm).select().first()
    if meeting:
            next =
URL('meetings','getmeetingpassword',args=meeting.id)
            redirect(URL('user',args='login',vars=dict(_next=next)))
    return dict(message=T(''))

I think you want
  (request.env.http_host or '').split('.')[0]
instead of
  request.env.http_host.split('.')[1]
but that is a guess.

On Sep 5, 8:07 am, "david.waldrop" <david.wald...@gmail.com> wrote:
> I have an application that uses the built in auth components.  Users
> can come to the site wither by hitting the root url, or via a link
> that has been emailed which contains a specific community.  What I
> want to happen is the following:
>
> 1) if a user enterswww.myapp.comthey get the default splash screen
> 2) if a user clicks a link form an invitation email
>        the user is sent to the login page
>        the user is sent to a function to validate the specific
> community password
>        if successful the user is taken to the specific community
>
> I have the function that validates the community password and
> redirects to the specific community
> the issue is that when I set auth.settings.login.next = myfunction it
> is not respected
>
> I have played with putting this in my model file, but got an error
> message form teh server saying too many redirects.  Ithink this is
> because the model is called so frequently.  I now have the following
> in my default/index controller:
>
> def index():
>     # if user clicked email link, redirect to longin and set url to
> get and check meeting password
>     meetingparm = request.env.http_host.split('.')[1]
>     if len(meetingparm):
>         meeting = db(db.meeting.link==meetingparm).select()
>         if len(meeting):     # user clicked a link with a valid
> meeting, lets get'em logged in and figure out who they are
>             meeting = meeting[0]
>             auth.settings.login_next =
> URL(r=request,c='meetings',f='getmeetingpassword',args=meeting.id)
>             redirect(URL(r=request,f='user',args='login'))
>     return dict(message=T(''))
>
> What happens when I click on the link is the login screen is displayed
> and after I enter credentials I am taking to the specific community,
> instead of the function that checks of community password.
>
> Do I have this is in the right place? if so, why isn't the
> 'getmeetingpassword' redirect taking affect?

Reply via email to