title: url redirect in flask-login
body: <p>I am trying to redirect the page upon successful login but I keep running into the same issue.  </p>
  
  <p>My login code:</p>
  
  <pre><code>@app.route('/login/', methods = ['GET', 'POST'])
  def login():
      if request.method == 'POST':
          #data = request.get_json()
          #app.logger.debug(data)
          auth = g.couch.get('_design/authentication')
          authView = ViewDefinition('_design/authentication','authentication',auth['views']['authentication']['map'])
          for row in authView():
              if request.form['username'] == row.value['username'] and request.form['password'] == row.value['password']:
                  authUser = userModel.User(row.value)
                  app.logger.debug(row.value)
                  authUser.authenticated = True;
                  flask_login.login_user(authUser,remember = True)
                  next = request.args.get('next')
                  return redirect(next or url_for('/protected/')) 
      return render_template('sampleLoginPage.html')
  
  @app.route('/protected/', methods = ['GET'])
  @flask_login.login_required
  def protected():
      app.logger.debug("Successful Login")
      app.logger.debug(flask_login.current_user.userID)
      return Response(json.dumps({'message' : '\'You\'re logged in so you can see this page'+flask_login.current_user.username}), mimetype = 'application/json')
  </code></pre>
  
  <p>The html template picks up the username and password.  I have a couchdb view that authenticates the user.</p>
  
  <p>When i enter my login credentials, the url redirects to <code>http://192.168.1.109:5000/login/?next=%2Fprotected%2F</code></p>
  
  <p>I did not fully understand the documentation.  Would someone be able to better explain this concept?  Why am I getting this?</p>
  
  <p>This is also coming up when i try to connect it to my angularjs front end.</p>
  
  <p>Regards,
  Sunil</p>