docs: def login(self, email=None, password=None, remember=False):
          """ Authenticate user and emit event. """
          from flask_login import login_user
          user = self.first(email=email)
          if user is None:
              events.login_failed_nonexistent_event.send()
              return False
  
          # check for account being locked
          if user.is_locked():
              raise x.AccountLocked(locked_until=user.locked_until)
  
          # check for email being confirmed
          is_new = user.email and not user.email_new
          if is_new and not user.email_confirmed and self.require_confirmation:
              raise x.EmailNotConfirmed(email=user.email_secure)
  
          verified = user.verify_password(password)
          if not verified:
              user.increment_failed_logins()
              self.save(user)
              events.login_failed_event.send(user)
              return False
  
          # login otherwise
          login_user(user=user, remember=remember)
          user.reset_login_counter()
          self.save(user)
          events.login_event.send(user)
  
          # notify principal
          app = current_app._get_current_object()
          identity_changed.send(app, identity=Identity(user.id))
  
          # and return
          return True