In gluon/tools.py line 1462:
cas = self.settings.login_form
cas_user = cas.get_user()
if cas_user:
cas_user[passfield] = None
user = self.get_or_create_user(cas_user)
elif hasattr(cas,'login_form'):
return cas.login_form()
else:
# we need to pass through login again before going on
next = self.url('user',args='login',vars=dict(_next=next))
redirect(cas.login_url(next))
It seems that "next" is hardcoded to URL('user', args='login'). If I
come from another URL such as 'facebook_login", after login I would
still be directed to .../user/login.
My workaround is to write a cookie in the controller:
def facebook_login():
# write a cookie to indicate that the user wants to login with
facebook
...
redirect(URL('user', args='login'))
def login():
...
# if there is a facebook cookie, use the login_form for
FacebookAccount
...
return dict(form=auth.login())
On Oct 12, 7:47 am, firedragon852 <[email protected]> wrote:
> If I remove:
> if request.args(0) == 'facebook':
>
> from the controller method, I can get authenticated by facebook and
> get redirected to the auth.settings.login_next URL.
>
> It seems that this is an all-or-nothing login mechanism. One
> application can only support one type of authentication method. Is
> this correct?
>
> On Oct 11, 8:49 pm, firedragon852 <[email protected]> wrote:
>
>
>
> > Hi, I have the following code:
>
> > def login():
> > ...
> > if request.args(0) == 'facebook':
> > from gluon.contrib.login_methods.oauth20_account import
> > OAuthAccount
> > auth.settings.login_form = FacebookAccount(globals())
> > return dict(form=auth.login())
>
> > When I go to the url .../login/facebook, I get directed to facebook's
> > login page. I can login successfully, but instead of going to
> > auth.settings.login_next, I get redirected to ../login. I think it is
> > because auth.settings.login_next is a URL that has
> > @auth.requires_login().
>
> > I want to be able to support both auth and facebook logins, and with
> > only ../login, auth.settings.login_form is not set and login will use
> > auth. Are there any problems with this approach?
>
> > I am using web2py version 1.86.2.