首页 > 解决方案 > Masonite - TypeError > 使用 Auth 登录方法时没有字符串参数的编码

问题描述

登录时,我不断收到TypeError > encoding without a string argument异常。我正在LoginController使用 Masonite 随附的开箱即用的产品进行操作。

登录路线很好,但登录时不断抛出此异常。

这是代码片段:

def store(self, request: Request, auth: Auth):
    if auth.login(request.input('email'), request.input('password')):
        return request.redirect('/home')

    return request.redirect('/login')

标签: pythonframeworksmasonite

解决方案


这很可能是因为您的输入之一丢失。如果其中一个输入丢失,它将是有价值的None,这将导致此异常。

检查 password 的值并确保它不是 type None


推荐阅读