stormpath / stormpath-flask

Build simple, secure web applications with Stormpath and Flask!
http://flask-stormpath.readthedocs.org/en/latest/
Other
155 stars 31 forks source link

/forgot POST 500 error #82

Closed mdeggies closed 8 years ago

mdeggies commented 8 years ago

Stacktrace:

[2016-11-21 13:27:25,192] ERROR in app: Exception on /forgot [POST]
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1988, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1641, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1544, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1625, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python2.7/site-packages/flask_stormpath/views.py", line 160, in forgot
    account = current_app.stormpath_manager.application.send_password_reset_email(form.email.data)
  File "/usr/local/lib/python2.7/site-packages/flask_stormpath/__init__.py", line 271, in application
    )[0]
  File "/usr/local/lib/python2.7/site-packages/stormpath/resources/base.py", line 469, in __getitem__
    return self.__dict__['items'][idx]
IndexError: list index out of range
127.0.0.1 - - [21/Nov/2016 13:27:25] "POST /forgot HTTP/1.1" 500

Steps to repro:

Add this to hello.py

from flask import Flask
from flask.ext.stormpath import StormpathManager
from os import environ

app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

app.config['SECRET_KEY'] = 's3cr3t'
app.config['STORMPATH_API_KEY_ID'] = environ.get('STORMPATH_API_KEY_ID')
app.config['STORMPATH_API_KEY_SECRET'] = environ.get('STORMPATH_API_KEY_SECRET')
app.config['STORMPATH_APPLICATION'] = environ.get('STORMPATH_APPLICATION_HREF')
app.config['STORMPATH_ENABLE_FORGOT_PASSWORD'] = True

stormpath_manager = StormpathManager(app)

if __name__ == '__main__':
    app.run()

Run export FLASK_APP=hello.py, flask run

Navigate to localhost:5000/forgot and enter in your email, click 'Submit'.

Python version: 2.7.2

rdegges commented 8 years ago

This works, the problem is that you have:'

app.config['STORMPATH_APPLICATION'] = environ.get('STORMPATH_APPLICATION_HREF')

This should be an application name, not href.