Flask-Security中的重置密码功能不起作用

时间:2013-02-25 05:02:41

标签: python flask flask-sqlalchemy flask-security

我正在尝试使用Flask-Security模块中的默认忘记密码功能而不进行自定义。在“忘记密码”视图中,我输入我的电子邮件地址,单击“恢复密码”并成功接收重置密码电子邮件。当我单击电子邮件中的链接时,我会按预期转到“重置密码”视图。当我尝试输入新密码并提交时,我得到了这个堆栈跟踪:

Traceback (most recent call last):
  File "/opt/virtualenvs/project/local/lib/python2.7/site-packages/flask/app.py", line 1701, in __call__
    return self.wsgi_app(environ, start_response)
  File "/opt/virtualenvs/project/local/lib/python2.7/site-packages/flask/app.py", line 1689, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/opt/virtualenvs/project/local/lib/python2.7/site-packages/flask/app.py", line 1687, in wsgi_app
    response = self.full_dispatch_request()
  File "/opt/virtualenvs/project/local/lib/python2.7/site-packages/flask/app.py", line 1360, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/opt/virtualenvs/project/local/lib/python2.7/site-packages/flask/app.py", line 1358, in full_dispatch_request
    rv = self.dispatch_request()
  File "/opt/virtualenvs/project/local/lib/python2.7/site-packages/flask/app.py", line 1344, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/opt/virtualenvs/project/local/lib/python2.7/site-packages/flask_security/decorators.py", line 171, in wrapper
    return f(*args, **kwargs)
  File "/opt/virtualenvs/project/local/lib/python2.7/site-packages/flask_security/views.py", line 264, in reset_password
    update_password(user, form.password.data)
  File "/opt/virtualenvs/project/local/lib/python2.7/site-packages/flask_security/recoverable.py", line 78, in update_password
    _datastore.put(user)
  File "/opt/virtualenvs/project/local/lib/python2.7/site-packages/flask_security/datastore.py", line 31, in put
    self.db.session.add(model)
  File "/opt/virtualenvs/project/local/lib/python2.7/site-packages/sqlalchemy/orm/scoping.py", line 149, in do
    return getattr(self.registry(), name)(*args, **kwargs)
  File "/opt/virtualenvs/project/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 1371, in add
    self._save_or_update_state(state)
  File "/opt/virtualenvs/project/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 1383, in _save_or_update_state
    self._save_or_update_impl(state)
  File "/opt/virtualenvs/project/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 1639, in _save_or_update_impl
    self._update_impl(state)
  File "/opt/virtualenvs/project/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 1633, in _update_impl
    self._attach(state)
  File "/opt/virtualenvs/project/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 1721, in _attach
    state.session_id, self.hash_key))
sqlalchemy.exc.InvalidRequestError: Object '<User at 0xa362a4c>' is already attached to session '33' (this is '34')

任何人都可以帮忙吗?

我正在使用:Flask == 0.9,Flask-SQLAlchemy == 0.16,Flask-Security == 1.5.4

0 个答案:

没有答案