3

我正在使用 Masonite 框架,craft auth在 Masonite 1.6 中运行命令后注册用户时出现错误。堆栈跟踪的结尾如下所示:

{% for i, line in enumerate(open(stack.filename)) %}

TypeError: Can't convert 'Undefined' object to str implicitly

4

1 回答 1

1

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.

Upgrade

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)

Patch

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')
于 2018-05-03T23:28:45.327 回答