Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed AttributeError: 'bytes' object has no attribute 'encode' #229

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion flask_user/token_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import base64
import string
import sys

# Non-system imports are moved into the methods to make them an optional requirement

Expand Down Expand Up @@ -43,7 +44,10 @@ def __init__(self, app):
raise ConfigError('Config setting SECRET_KEY is missing.')

# Print a warning if SECRET_KEY is too short
key = flask_secret_key.encode()
if sys.version_info[0] < 3:
key = flask_secret_key.encode()
else:
key = flask_secret_key
if len(key)<32:
print('WARNING: Flask-User TokenManager: SECRET_KEY is shorter than 32 bytes.')
key = key + b' '*32 # Make sure the key is at least 32 bytes long
Expand Down