I'm trying to do the modal login thing. I'm LOADing the auth login
form into a div, which is id'd as a dialog for jquery ui. Should be a
snap, right? Wrong. It's not working at all.
First, I ran into the problem I describe in another thread, which is
that I'm forced to do this:
session._auth_next = auth.settings.login_next = URL(c='user',
f='login')
because otherwise, session._auth_next will drive me to the default
index.
The other problem I have is that I can't figure out how to get the
flow of the form submission to recognize response.js and execute the
ajax call after login is completed. I've tried putting response.js
into a function in my 0_db.py file, like this:
def myonaccept(form):
response.js = ...
auth.settings.login_onaccept = [myonaccept]
but that doesn't seem to do anything.
I've also tried changing the login function to something like this:
def login():
auth.settings.captcha = None
login_form = auth.login()
if login_form.accepts(request):
response.flash = 'yo dude'
response.js = util.clean_str(
'ajax("%s",[],":eval");' % URL(c='user',
f='cb_after_login'))
return dict(login_form=login_form)
But that also doesn't work. I get tied up with a nasty ticket:
...
if login_form.accepts(request):
File "N:\web2py\gluon\sqlhtml.py", line 1267, in accepts
self.vars.id = self.table.insert(**fields)
File "N:\web2py\gluon\dal.py", line 5597, in insert
return self._db._adapter.insert(self,self._listify(fields))
File "N:\web2py\gluon\dal.py", line 914, in insert
raise e
IntegrityError: duplicate key value violates unique constraint
"auth_user_email_key"
Any help or working examples would be appreciated. On, and I have
multiple forms going on the page, so that might be an issue, too.