简体   繁体   English

AttributeError:“函数”对象没有属性“ verify_password”

[英]AttributeError: 'function' object has no attribute 'verify_password'

I am trying to incorporate basic authentication as shown in this link 我正在尝试结合此链接中所示的基本身份验证

https://github.com/miguelgrinberg/Flask-HTTPAuth/blob/master/examples/basic_auth.py https://github.com/miguelgrinberg/Flask-HTTPAuth/blob/master/examples/basic_auth.py

in my flask app. 在我的烧瓶应用程序中。 The app is deployed on Heroku. 该应用程序已部署在Heroku上。 The error I keep getting is 我不断收到的错误是

@auth.verify_password 
AttributeError: 'function' object has no attribute 'verify_password'

Below is my code 下面是我的代码

import urllib
import json
import os
import string
import random

from flask import Flask,render_template,request
from sqlalchemy import create_engine, asc
from sqlalchemy.orm import sessionmaker
from database_setup import Base, User
from flask import Flask,render_template
from flask import request
from flask import make_response
from flask import session as login_session
from flask import make_response
from flask_httpauth import HTTPBasicAuth
from werkzeug.security import generate_password_hash, check_password_hash

@auth.verify_password
def verify_password(username_or_token, password):
    #Try to see if it's a token first
    user_id = User.verify_auth_token(username_or_token)
    if user_id:
        user = session.query(User).filter_by(id = user_id).one()
    else:
        user = session.query(User).filter_by(username = username_or_token).first()
        if not user or not user.verify_password(password):
            return False
    g.user = user
    return True

Below is the traceback 下面是回溯

2017-02-14T19:28:58.375416+00:00 heroku[web.1]: State changed from crashed to starting
2017-02-14T19:29:01.124995+00:00 heroku[web.1]: Starting process with command `python test.py`
2017-02-14T19:29:04.255161+00:00 heroku[web.1]: Process exited with status 1
2017-02-14T19:29:04.127534+00:00 app[web.1]: Traceback (most recent call last):
2017-02-14T19:29:04.127556+00:00 app[web.1]:   File "test.py", line 234, in <module>
2017-02-14T19:29:04.127594+00:00 app[web.1]:     @auth.verify_password
2017-02-14T19:29:04.127622+00:00 app[web.1]: AttributeError: 'function' object has no attribute 'verify_password'
2017-02-14T19:29:04.299349+00:00 heroku[web.1]: State changed from starting to crashed
2017-02-14T19:29:04.300161+00:00 heroku[web.1]: State changed from crashed to starting

My requirements.txt file contains the following 我的requirements.txt文件包含以下内容

click==6.7
Flask==0.12
httplib2==0.9.2
itsdangerous==0.24
Jinja2==2.9.4
MarkupSafe==0.23
passlib==1.7.0
SQLAlchemy==1.1.5
virtualenv==15.1.0
Werkzeug==0.11.15
Flask-HTTPauth==3.2.2

Can someone help me figure out what the issue is? 有人可以帮我找出问题所在吗? I have all the correct imports as suggested on the GitHub example and also have them correctly mentioned in my requirements.txt file. 我具有GitHub示例上建议的所有正确导入,并且在我的requirements.txt文件中也已正确提及它们。 Thanks in advance. 提前致谢。

The same question was posted on the GitHub repository, and was resolved there. 相同的问题发布在GitHub存储库上,并在那里得到解决。 Link: https://github.com/miguelgrinberg/Flask-HTTPAuth/issues/53 链接: https//github.com/miguelgrinberg/Flask-HTTPAuth/issues/53

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AttributeError:“ Flask”对象没有属性“ rout” - AttributeError: 'Flask' object has no attribute 'rout' Heroku 无法启动 Python Flask 应用程序(“ AttributeError: &#39;function&#39; object has no attribute &#39;uses_netloc&#39; ”) - Heroku Can't Launch Python Flask App (“ AttributeError: 'function' object has no attribute 'uses_netloc' ”) AttributeError:&#39;ParseResult&#39;对象没有属性&#39;drivername&#39; - AttributeError: 'ParseResult' object has no attribute 'drivername' AttributeError: &#39;WSGIRequest&#39; 对象没有属性 &#39;get&#39; heroku - AttributeError: 'WSGIRequest' object has no attribute 'get' heroku AttributeError:'RegexURLResolver'对象没有属性'_urlconf_module' - AttributeError: 'RegexURLResolver' object has no attribute '_urlconf_module' python celery AttributeError: &#39;int&#39; 对象没有属性 &#39;upper&#39; 错误 - python celery AttributeError: 'int' object has no attribute 'upper' error Heroku和Pip:AttributeError:&#39;_NamespacePath&#39;对象没有属性&#39;sort&#39; - Heroku & Pip: AttributeError: '_NamespacePath' object has no attribute 'sort' /admin &#39;AnonymousUser&#39; 对象的 AttributeError 没有属性 &#39;first_name&#39; - AttributeError at /admin 'AnonymousUser' object has no attribute 'first_name' AttributeError: 'tuple' object 在 Heroku 日志上没有属性 'decode' - AttributeError: 'tuple' object has no attribute 'decode' on Heroku logs AttributeError:“ NoneType”对象没有属性,因为相关的对象没有在视图中 - AttributeError: 'NoneType' object has no attribute due to related object slug not in view
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM