title: Flask-Security Error - NameError: global name 'verify_and_update_password' is not defined
body: <p>Please excuse my ignorance!</p>
  
  <p>I've followed the tutorial for flask-security with MongoEngine and keep getting the following error below when I try to signed in with a registered user account.</p>
  
  <blockquote>
    <p>NameError: global name 'verify_and_update_password' is not defined</p>
  </blockquote>
  
  <p>I've looked through the <a href="https://github.com/inveniosoftware/flask-security-fork/blob/master/flask_security/utils.py" rel="nofollow noreferrer">Flask-Security utils</a> file and can't figure out what I'm doing wrong. My code is below:</p>
  
  <pre><code>import datetime
  from flask import Flask, url_for, render_template, request, redirect, session, flash
  from flask_mongoengine import MongoEngine
  from mongoengine.document import Document
  from mongoengine.fields import *
  import bcrypt
  import flask_security
  from flask_security import Security, MongoEngineUserDatastore, UserMixin, RoleMixin, login_required, ConfirmRegisterForm
  from flask_login import LoginManager, UserMixin, current_user, login_user, logout_user
  
  # Create app
  app = Flask(__name__)
  
  # MongoDB Configuration
  app.config['MONGODB_DB'] = 'testdb'
  app.config['MONGODB_HOST'] = 'localhost'
  app.config['MONGODB_PORT'] = 27017
  
  app.config['SECURITY_PASSWORD_SALT'] = 'bcrypt'
  app.config['SECURITY_CONFIRMABLE'] = True
  app.config['SECURITY_REGISTERABLE'] = True
  app.config['SECURITY_RECOVERABLE'] = True
  app.config['SECURITY_TRACKABLE'] = True
  app.config['SECURITY_CHANGEABLE'] = True
  app.config['SECURITY_SEND_REGISTER_EMAIL'] = True
  
  # Flask Mail Configuration
  app.config['MAIL_SERVER'] = 'my.secureserver.net'
  app.config['MAIL_PORT'] = 465
  app.config['MAIL_USE_SSL'] = True
  app.config['MAIL_USERNAME'] = 'noreply@mymail.com'
  app.config['MAIL_PASSWORD'] = '3nj8$5jd#9n834'
  
  db = MongoEngine(app)
  mail = Mail(app)
  login = LoginManager(app)
  
  class Role(db.Document, RoleMixin):
      name = db.StringField(max_length=80, unique=True)
  
  class User(db.Document, UserMixin):
      email = db.EmailField(max_length=255, unique=True)
      password = db.StringField(max_length=255)
      active = db.BooleanField(default=True)
      joined_at = db.DateTimeField(default=datetime.datetime.now)
      confirmed_at = db.DateTimeField()
      roles = db.ListField(db.StringField(), default=['admin'])
  
  # Setup Flask-Security
  user_datastore = MongoEngineUserDatastore(db, User, Role)
  security = Security(app, user_datastore)
  
  if __name__ == '__main__':
      app.run(host='0.0.0.0')
  </code></pre>