title: Check login status flask
body: <p>I'm creating a website with the login system and this is what i'm dealing with:</p>
  
  <p>I have two routes:</p>
  
  <p>The first one is the login page, here is the code:</p>
  
  <pre><code>@app.route('/login')
  def login():
      return render_template('login.html')
  
  @app.route('/login', methods=['POST'])
  def login_submit():
      error = None
      if request.form['username'] == 'khoa.programmer' and request.form['password'] == 'HotnCold':
          if request.form['actions'] == 'add-post':
              return redirect('/admin/addpost')
      else:
          error = 'Wrong info'
          return render_template('login.html', error=error)
  </code></pre>
  
  <p>and the second one is the addpost route will be redirected after user logged in. </p>
  
  <p>The problem is i don't know how or what to check that user logged in successfully. I want to prevent people just type the url and access the page without permission, simply just show a message to them or redirect them to the login page. Please help!</p>
  
  <p>Sorry about my english!</p>