title: Flask-login error , python
body: <p>I'm new to python/flask and am trying to build app using flask-login. I can't get my head around the error I'm getting "object has no attribute 'get_id'" Appreciate your help.  </p>
  
  <pre><code>class User(UserMixin):
      def __init__(self, email, id, active=True):
          self.email = email
          self.id = id
          #self.active = active
  
      def get_id(self):
          return self.id
  
      def is_active(self):
          # Here you should write whatever the code is
          # that checks the database if your user is active
          return True
  
      def is_anonymous(self):
          return False
  
      def is_authenticated(self):
          return True
  
  login_manager = LoginManager()
  login_manager.init_app(app)
  
  
   # load_user .. never makes it till here 
   @login_manager.user_loader
   def load_user(userid):
       try:
           print 'this gets executed:--', userid
           return User.get(User.id==userid)
       except User.DoesNotExist:
           return None
  
  
  @app.route('/confirm/&lt;token&gt;', methods=['GET', 'POST'])
  def confirm_email(token):
      try:
          email = confirm_token(token)
          print email
      except:
          flash('The confirmation link is invalid or has expired.', 'danger')
  
      userExists = db.userExists(email)
  
      if userExists:
          flash('Account already confirmed. Please login.', 'success')
          login_user(userExists, force=True, remember=True)
      else:
          flash('You have confirmed your account. Thanks!', 'success')
          confirm_login()
          login_user(userExists, force=True, remember=True)
      return redirect(url_for('Hello'))
  </code></pre>
  
  <p>code for db</p>
  
  <pre><code>def userExists(email):
      SQL = """SELECT * FROM all_users WHERE email = %s"""
      data = (email,)
      records = runQuery(SQL, data)
      if records and records[0]:
          return records[0][0]
      else:
          records
  </code></pre>
  
  <p>Error that I'm getting:</p>
  
  <pre><code> File "/Documents/Dev/Ottawa-Final/ottawa-final/app/network_of_innovators.py", line 310, in confirm_email
      login_user(userExists, force=True, remember=True)
    File "/Documents/Dev/lib/python2.7/site-packages/flask_login.py", line 678, in login_user
      user_id = getattr(user, current_app.login_manager.id_attribute)()
  AttributeError: 'str' object has no attribute 'get_id'
  </code></pre>