I am trying to create a decorator function, which checks if user's email is verified, but I am getting this error.
AttributeError: 'NoneType' object has no attribute 'verified_email'
Does somebody know how to solve it?
def email_verified(func):
def check_verification():
user = current_user
if user.verified_email == True:
return func()
else:
flash("verify your email")
return redirect(url_for(index))
return check_verification()
CodePudding user response:
The definition needs the current_user as some kind of input.
CodePudding user response:
Try adding a check like this
...
if user and user.verified_email:
return func()
else:
...