Not tested, but maybe something like this:
from gluon.contrib.login_methods.ldap_auth import ldap_auth
def store_login_method(method, label):
def login(username, password, method=method, label=label):
result = method(username, password)
session.login_method = label if result else None
return result
return login
def after_login(form):
[do something with session.login_method]
ldap = dict(ldapA=ldap_auth(...),
ldapB=ldap_auth(...))
auth.settings.login_methods.extend([store_login_method(method, label)
for method, label in ldap.iteritems()])
auth.settings.login_onaccept.append(after_login)
After a successful login, the label ("ldapA" or "ldapB") will be stored in
session.login_method. You can then grab it there and do whatever you want
with it.
Anthony
On Tuesday, December 15, 2015 at 4:20:46 PM UTC-5, Jonathan R wrote:
>
> It seems like no one has any clue about this..
>
> I was thinking about modifying the code inside gluon.tools to use
> enumerate() on the for loop parsing auth.settings.login_methods in order to
> have an index of the auth_method that succeed and from here determine the
> server.
>
> I'm not quite sure where I should add this enumerate, I found several
> places where login_method was used and I couldn't figure out which one it
> is.
>
> I would rather not touch web2py base code but I'm out of idea.
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.