我正在使用 Masonite 框架,craft auth
在 Masonite 1.6 中运行命令后注册用户时出现错误。堆栈跟踪的结尾如下所示:
{% for i, line in enumerate(open(stack.filename)) %}
TypeError: Can't convert 'Undefined' object to str implicitly
我正在使用 Masonite 框架,craft auth
在 Masonite 1.6 中运行命令后注册用户时出现错误。堆栈跟踪的结尾如下所示:
{% for i, line in enumerate(open(stack.filename)) %}
TypeError: Can't convert 'Undefined' object to str implicitly
This was fixed in Masonite 1.6.3. The problem was that there was a bug with passwords not being decoded back into a string after being hashed with bcrypt. Apparently MySQL converts bytes into a string before inserting into the database but Postgres and SQLite does not.
The fix is to upgrade Masonite by running:
pip install --upgrade -r requirements.txt
to upgrade to the latest version (so craft auth
will not create a controller with this bug again)
and to patch the current application by changing ~line 20 in your RegisterController to:
password = bytes(bcrypt.hashpw(
bytes(Request.input('password'), 'utf-8'), bcrypt.gensalt()
)).decode('utf-8')