def auth_basic():
 auth = request.authorization
 if (not auth):
  return (False, '')
 user = UserModel.query.filter_by(email=auth.username).first()
 auth_ok = False
 if (user is not None):
  auth_ok = check_password_hash(auth.password.encode('utf-8'), user.password.encode('utf-8'), user.salt)
 if (not auth_ok):
  return (False, 'Authentication failed. Wrong username or password')
 g.user = user
 return (True, '')

def auth_basic ( ) : auth = request . authorization if ( not auth ) : return ( False , '' ) user = UserModel . query . filter_by ( email = auth . username ) . first ( ) auth_ok = False if ( user is not None ) : auth_ok = check_password_hash ( auth . password . encode ( 'utf-8' ) , user . password . encode ( 'utf-8' ) , user . salt ) if ( not auth_ok ) : return ( False , 'Authentication failed. Wrong username or password' ) g . user = user return ( True , '' )
callback decorator to require http auth .