这是我的 Python EVE 代码
from eve import Eve
from eve.auth import BasicAuth
class MyBasicAuth(BasicAuth):
def check_auth(self, username, password, allowed_roles, resource,
method):
if resource == 'auth':
user = app.data.driver.db['user']
user = user.find_one({'email': username,'password':password})
if user:
return user
else:
False
else:
return True
app = Eve(auth=MyBasicAuth)
if __name__ == '__main__':
app.run()
验证成功后,我将返回user
对象,但没有返回任何内容。我哪里错了。这是settings.py文件
RESOURCE_METHODS = ['GET', 'POST']
DOMAIN = {
'user': {
'schema': {
'firstname': {
'type': 'string'
},
'lastname': {
'type': 'string'
},
'email': {
'type': 'string'
},
'password': {
'type': 'string'
},
'phone': {
'type': 'string'
}
}
},
'auth': {
'schema': {
'username': {
'type': 'string'
},
'password': {
'type':'string'
}
}
}
}