I'm beginning to learn user authentication. I've implemented a very
basic authentication using the Auth module that works fine on my local
machine: I can register a user, a confirmation email is sent out, the
user can confirm his email, login and logout.
I copied the app to a remote server and tried to register a user, but
after I entered all the user information and hit Submit I got
redirected back to the registration page and no email was sent to the
user being registered, no ticket was generated either.
I'd appreciate any clues.
I'm using web2py 1.59. My local machine is a WinXP box, the remote
server is on a Linux distro.
Thanks.
--
Alexei Vinidiktov
Additional info:
After my unsuccessful attempt to register I was redirected to the same
registration page (which is just a scaffold provided by web2py) and
then I looked at the session info by clicking on the corresponding
button and it said "auth : None, flash : Invalid email", but no flash
was shown to the user (i.e. to me). I tried different email, but
always got the same flash : invalid email in the session info.
--
Alexei Vinidiktov
I've updated my web2py installation on the remote server to the latest
version, but it didn't help.
Do you have any guesses at all as to what may be happening?
--
Alexei Vinidiktov
Another piece of information.
Logging in and logging out both do seem to work on the remote server,
only registration of new users doesn't work.
--
Alexei Vinidiktov
web2py doesn't handle this automaticaly. You can change this message
with something like this:
from gluon.tools import Auth
auth = Auth(...)
...
auth.messages.verify_email = 'Click on the link
http://Your_site's_URL/verify_email/%(key)s to verify your email'
It can be added in future to web2py handles that automaticaly, getting
data from request - but for this work we must implement a way to get
FULL URL requested by user - it is a routes.py feature that I
requested some time ago.
--
Álvaro Justen
Peta5 - Telecomunicações e Software Livre
21 3021-6001 / 9898-0141
http://www.peta5.com.br/
Thanks, Álvaro!
Are there any hard to overcome obstacles to implementing your feature request?
--
Alexei Vinidiktov
I think we can modify it to:
if self.settings.mailer:
user[form.vars.id] = dict(registration_key=key)
if not self.settings.mailer.send(to=form.vars.email,
subject=self.messages.verify_email_subject,
message=self.messages.verify_email
% dict(key=key)):
self.db.rollback()
"""<CHANGED>""""
session.flash = self.messages.cant_send_mail
"""</CHANGED>""""
return form
session.flash = self.messages.email_sent
else:
session.flash = self.messages.registration_successful
And add:
self.messages.cant_send_mail = 'Error sending verification
email. Try again later.''
If it is a valid or not email, we can verify with IS_EMAIL() valitator
- it is OK, Auth.define_tables() just do it.
You're welcome.
> Are there any hard to overcome obstacles to implementing your feature request?
I don't know how web2py receives and handles requests from web server
- I didn't study this part of web2py's code. So, Massimo is the best
person to tell us about this.
Hi Alexei,
there is a new feature in trunk: request.env.original_uri. With this
and other request.env vars (path_info, http_host) I think you can do
what you want (specify verification URL in a "dynamic" way).