I am trying to build a user login system and I have successfully built the user register page, but when I try to login I get the error below. I am using flask, python3.6 and pymongo.
This is the error: AttributeError: 'bytes' object has no attribute 'encode'
please help.
Traceback (most recent call last): File "C:\Users\elvis\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 2309, in call return self.wsgi_app(environ, start_response) File "C:\Users\elvis\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 2295, in wsgi_app response = self.handle_exception(e) File "C:\Users\elvis\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1741, in handle_exception reraise(exc_type, exc_value, tb) File "C:\Users\elvis\AppData\Local\Programs\Python\Python36\lib\site-packages\flask_compat.py", line 35, in reraise raise value File "C:\Users\elvis\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "C:\Users\elvis\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "C:\Users\elvis\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "C:\Users\elvis\AppData\Local\Programs\Python\Python36\lib\site-packages\flask_compat.py", line 35, in reraise raise value File "C:\Users\elvis\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "C:\Users\elvis\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1799, in dispatch_request return self.view_functionsrule.endpoint File "C:\Users\elvis\Desktop\flask apps\testmon\even\app\run.py", line 30, in login if bcrypt.hashpw(request.form['pass'].encode('utf-8'), login_user['password']) == login_user['password'].encode('utf-8'): AttributeError: 'bytes' object has no attribute 'encode'