title: Flask login without database
body: <p>I need to implement a simple login functionality to one of the applications that I a working on using <code>flask-login</code>. The authentication checking is hardcoded if condition and it is validating whether username password equals to a string given. The code is like the following:</p>
  <pre><code>@auth_bp.route('/login', methods=[&quot;POST&quot;])
  def loginHandler():
      username = request.form.get('username')
      password = request.form.get('password')
  
      if username != 'admin' and password != 'Admin@123':
          flash('Please check your login details and try again.')
          return redirect(url_for('auth_bp.show_login'))
  
      login_user(username, False)
      # if the above check passes, then we know the user has the right credentials
      return redirect(url_for('migration_bp.list'))
  </code></pre>
  <p>and in <code>app.py</code> file, I have the following code:</p>
  <pre><code>from flask import Flask
  from flask_login import LoginManager, login_manager
  from auth.auth import auth_bp
  from environments.environments import environments_bp
  from migration.migration import migration_bp
  from logs.logs import logs_bp
  
  UPLOAD_FOLDER = 'static/uploads'
  
  @login_manager.user_loader
  def user_loader():
      # since the user_id is just the primary key of our user table, use it in the query for the user
      return 1
  
  def create_app():
  
      app = Flask(__name__)
  
      login_manager_copy = LoginManager()
      login_manager_copy.login_view = 'auth.login'
      login_manager_copy.init_app(app)
  
      app.register_blueprint(auth_bp, url_prefix='/auth')
      app.register_blueprint(environments_bp, url_prefix='/environments')
      app.register_blueprint(migration_bp, url_prefix='/migration')
      app.register_blueprint(logs_bp, url_prefix='/logs')
  
      app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
      app.secret_key = b'_5#y2L&quot;F4Q8z\n\xec]/'
  
      return app
  
  
  if __name__ == '__main__':
      create_app().run(debug=True)
  </code></pre>
  <p>But this is showing an error as follows:</p>
  <pre><code>AttributeError: module 'flask_login.login_manager' has no attribute 'user_loader'
  </code></pre>
  <p>As I don't need database, I think the User modal given in the examples are not needed. But it is giving errors without it. How can I fix this ?</p>
  <p>EDIT:</p>
  <p>As per the suggestion below, I have added a User class as shown below:</p>
  <pre><code>from flask_login import UserMixin, LoginManager, login_manager
  
  
  class User(UserMixin):
  
      def is_authenticated(self):
          return True
  
      def is_active(self):
          return True
  
      def is_anonymous(self):
          return False
  
      def get_id(self):
          return int(self.id)
  
      def __repr__(self):
          return f&quot;User('{self.username}', '{self.email}', '{self.powerlevel}')&quot;
  </code></pre>
  <p>and added following code to <code>app.py</code> file:</p>
  <pre><code>@login_manager.user_loader
      def load_user(user_id):
          # since the user_id is just the primary key of our user table, use it in the query for the user
          return User.query.get(int(user_id))
  </code></pre>
  <p>But it is still showing the same error.</p>