lingthio / Flask-User-starter-app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot create new user?

scheung38 opened this issue · comments

Have tried using the default
env_settings_example.py as well as using my own env_settings.py, but they all cannot register new users?

Have been able to sign in using default admin and user:

Test users:

But cannot create new user:

127.0.0.1 - - [07/Sep/2015 13:07:34] "GET /user/register HTTP/1.1" 200 -
127.0.0.1 - - [07/Sep/2015 13:08:10] "POST /user/register HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/home/osboxes/anaconda/envs/py27/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/osboxes/anaconda/envs/py27/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/home/osboxes/anaconda/envs/py27/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/osboxes/anaconda/envs/py27/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/osboxes/anaconda/envs/py27/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/osboxes/anaconda/envs/py27/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/osboxes/anaconda/envs/py27/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/osboxes/anaconda/envs/py27/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/osboxes/anaconda/envs/py27/lib/python2.7/site-packages/flask_user/views.py", line 423, in register
    _send_registered_email(user, user_email, require_email_confirmation)
  File "/home/osboxes/anaconda/envs/py27/lib/python2.7/site-packages/flask_user/views.py", line 662, in _send_registered_email
    emails.send_registered_email(user, user_email, confirm_email_link)
  File "/home/osboxes/anaconda/envs/py27/lib/python2.7/site-packages/flask_user/emails.py", line 148, in send_registered_email
    user_manager.send_email_function(email, subject, html_message, text_message)
  File "/home/osboxes/anaconda/envs/py27/lib/python2.7/site-packages/flask_user/emails.py", line 49, in send_email
    mail_engine.send(message)
  File "/home/osboxes/anaconda/envs/py27/lib/python2.7/site-packages/flask_mail.py", line 491, in send
    with self.connect() as connection:
  File "/home/osboxes/anaconda/envs/py27/lib/python2.7/site-packages/flask_mail.py", line 144, in __enter__
    self.host = self.configure_host()
  File "/home/osboxes/anaconda/envs/py27/lib/python2.7/site-packages/flask_mail.py", line 156, in configure_host
    host = smtplib.SMTP_SSL(self.mail.server, self.mail.port)
  File "/home/osboxes/anaconda/envs/py27/lib/python2.7/smtplib.py", line 796, in __init__
    SMTP.__init__(self, host, port, local_hostname, timeout)
  File "/home/osboxes/anaconda/envs/py27/lib/python2.7/smtplib.py", line 256, in __init__
    (code, msg) = self.connect(host, port)
  File "/home/osboxes/anaconda/envs/py27/lib/python2.7/smtplib.py", line 316, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/home/osboxes/anaconda/envs/py27/lib/python2.7/smtplib.py", line 801, in _get_socket
    new_socket = socket.create_connection((host, port), timeout)
  File "/home/osboxes/anaconda/envs/py27/lib/python2.7/socket.py", line 557, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
TypeError: getaddrinfo() argument 1 must be string or None
127.0.0.1 - - [07/Sep/2015 13:08:10] "GET /user/register?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 200 -
127.0.0.1 - - [07/Sep/2015 13:08:10] "GET /user/register?__debugger__=yes&cmd=resource&f=jquery.js HTTP/1.1" 200 -
127.0.0.1 - - [07/Sep/2015 13:08:10] "GET /user/register?__debugger__=yes&cmd=resource&f=debugger.js HTTP/1.1" 200 -
127.0.0.1 - - [07/Sep/2015 13:08:10] "GET /user/register?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 -
127.0.0.1 - - [07/Sep/2015 13:08:10] "GET /user/register?__debugger__=yes&cmd=resource&f=source.png HTTP/1.1" 200 -

I'm having the exact same problem. Same error message:

TypeError: getaddrinfo() argument 1 must be string or None

Any idea what's going on with this or plans to fix it?

I found the solution to the problem!
So this system will attempt to email the users as they register. It's failing to email users because your env_settings_example.py isn't correct.

The env_settings_example.py is setting the MAIL_SERVER variable like this:
MAIL_SERVER = 'MAIL_SERVER', 'smtp.gmail.com'

When python uses the above MAIL_SERVER variable, it is coming in as a Tuple data type. This is causing the TypeError @Hendeca mentions above. The socket.getaddrinfo() function requires a String for the 1st argument (the 1st argument is the host; See Here)

Try tweaking your env_settings so the mail server is in the format below. The variable should simply equal a string.

MAIL_USERNAME = 'username@gmail.com'
MAIL_PASSWORD = 'gmailpassword'
MAIL_DEFAULT_SENDER = '"AppName" username@gmail.com'
MAIL_SERVER = 'smtp.gmail.com'
MAIL_PORT = 465
MAIL_USE_SSL = True
MAIL_USE_TLS = False