0

When running the web server and attempting to purchase stocks, I run into this very odd error regarding the register() function. I had to change pwd_context.encrypt() to pwd_context.hash() since the former doesn't exist anymore, and now it does not work.

File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", line 1997, in __call__

return self.wsgi_app(environ, start_response)

File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", line 1985, in wsgi_app

response = self.handle_exception(e)

File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", line 1540, in handle_exception

reraise(exc_type, exc_value, tb)

File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise

raise value

File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app

response = self.full_dispatch_request()

File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", line 1614, in full_dispatch_request

rv = self.handle_user_exception(e)

File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", line 1517, in handle_user_exception

reraise(exc_type, exc_value, tb)

File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise

raise value

File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", line 1612, in full_dispatch_request

rv = self.dispatch_request()

File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/flask/app.py", line 1598, in dispatch_request

return self.view_functions[rule.endpoint](**req.view_args)

File "/home/ubuntu/workspace/pset7/finance/application.py", line 227, in register

result = db.execute("INSERT INTO users (username, hash) VALUES(:username, :hash)", username=request.form.get("username"), hash=pwd_context.hash(request.form.get("password")))

File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/passlib/context.py", line 2253, in hash

return record.hash(secret, **kwds)

File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/passlib/utils/handlers.py", line 746, in hash

validate_secret(secret)

File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/passlib/utils/handlers.py", line 122, in validate_secret

raise exc.ExpectedStringError(secret, "secret")

TypeError: secret must be unicode or bytes, not None
0

Is request.form.get("password") returning a string? If so, are you sure? Have you for example printed the value to the console?

I guess it's returning None instead, maybe because of a typo, input name in form not being "password".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .