title: Flask-login not redirecting to previous page
body: <p>I have seen quite a few questions with this in mind, but haven't been able to address my issue. I have a Flask app with flask-login for session management. And, when I try to view a page without logging in, I get redirected to a link in form of <code>/login/?next=%2Fsettings%2F</code></p>
  
  <p>The issue is, as far as I could have it understand, that the "next" argument holds the part of the site I actually need, but when submitting a request to a login form, it is done via <code>POST</code>, so this argument is no longer available for me to redirect it to.</p>
  
  <p>I tried using <code>Request.path</code> from <a href="http://flask.pocoo.org/docs/api/#flask.Request.path%20Request" rel="noreferrer">Request</a> (and url) but both just return the <code>/login/</code> as the request url/path, not the actual <code>/login/?next=xxx</code>.</p>
  
  <p>My login method is as follows:</p>
  
  <pre><code>@app.route('/login/', methods=['GET', 'POST'])
  def login():
      if request.method == 'POST':
          #getting the user
          user = User.get(request.form['username'])
          if user.user is None:
              return redirect('/login/')
          #actual login proces
          if user and check_password_hash(user.user.password, request.form['password']):
              login_user(user, remember=remember)
              #the redirection portion of the login process
              return redirect(request.path or ("/")) # I tried various options there but without success, like request.args['next'] and such
  
          return redirect('/login/')
  
      else:
          return redirect('/')
  </code></pre>
  
  <p>Thanks</p>