# Path: mass_flask_core/models/user.py
# class User(db.Document, UserMixin):
#     def is_authenticated(self):
#         return True
# 
#     username = StringField(min_length=3, max_length=50, unique=True, required=True)
#     password_hash = StringField(min_length=5, max_length=200)
#     user_level = UserLevelField(default=UserLevel.USER_LEVEL_USER, required=True)
# 
#     def set_password(self, password):
#         self.password_hash = generate_password_hash(password)
# 
#     def check_password(self, password):
#         return check_password_hash(self.password_hash, password)
# 
#     def get_id(self):
#         return str(self.id)
# 
#     @staticmethod
#     def user_loader(**kwargs):
#         if 'username' in kwargs and 'password' in kwargs:
#             user = User.objects(username=kwargs['username']).first()
#             if user and user.check_password(kwargs['password']):
#                 return user
#             else:
#                 return None
#         elif 'id' in kwargs and kwargs['id']:
#             return User.objects(id=ObjectId(kwargs['id'])).first()
#         else:
#             raise RuntimeError('This access method is not supported by the user loader.')
# 
# class UserLevel:
#     USER_LEVEL_ANONYMOUS = 0
#     USER_LEVEL_USER = 1
#     USER_LEVEL_PRIVILEGED = 2
#     USER_LEVEL_MANAGER = 3
#     USER_LEVEL_ADMIN = 4
# 
# Path: mass_flask_config/app.py
# BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# SECRET_FILE = os.path.join(BASE_DIR, 'secret.txt')
# def setup_session_auth(user_loader):
# def setup_key_based_auth(key_loader):
# def unauthorized_callback():


from getpass import getpass
from mass_flask_core.models import User, UserLevel
from mass_flask_config.app import app

if __name__ == '__main__':
    print('mass-server-flask version' + app.version)
    username = input('Please enter username to create: ')
    password = getpass(prompt='Please enter the password for the new user: ')
    password_verify = getpass(prompt='Enter password again to verify: ')
    if password != password_verify:
        print('Passwords do not match. Exiting.')
        exit(1)
    make_admin = False
    while True:
        input_admin = input('Should the new user have admin privileges? [y/n] ')
        if input_admin == 'y':
            make_admin = True
            break
        elif input_admin == 'n':
            make_admin = False
            break

# Path: mass_flask_core/models/user.py
# class User(db.Document, UserMixin):
#     def is_authenticated(self):
#         return True
# 
#     username = StringField(min_length=3, max_length=50, unique=True, required=True)
#     password_hash = StringField(min_length=5, max_length=200)
#     user_level = UserLevelField(default=UserLevel.USER_LEVEL_USER, required=True)
# 
#     def set_password(self, password):
#         self.password_hash = generate_password_hash(password)
# 
#     def check_password(self, password):
#         return check_password_hash(self.password_hash, password)
# 
#     def get_id(self):
#         return str(self.id)
# 
#     @staticmethod
#     def user_loader(**kwargs):
#         if 'username' in kwargs and 'password' in kwargs:
#             user = User.objects(username=kwargs['username']).first()
#             if user and user.check_password(kwargs['password']):
#                 return user
#             else:
#                 return None
#         elif 'id' in kwargs and kwargs['id']:
#             return User.objects(id=ObjectId(kwargs['id'])).first()
#         else:
#             raise RuntimeError('This access method is not supported by the user loader.')
# 
# class UserLevel:
#     USER_LEVEL_ANONYMOUS = 0
#     USER_LEVEL_USER = 1
#     USER_LEVEL_PRIVILEGED = 2
#     USER_LEVEL_MANAGER = 3
#     USER_LEVEL_ADMIN = 4
# 
# Path: mass_flask_config/app.py
# BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# SECRET_FILE = os.path.join(BASE_DIR, 'secret.txt')
# def setup_session_auth(user_loader):
# def setup_key_based_auth(key_loader):
# def unauthorized_callback():


# Path: mass_flask_bin/create_user.py
from getpass import getpass
from mass_flask_core.models import User, UserLevel
from mass_flask_config.app import app


if __name__ == '__main__':
    print('mass-server-flask version' + app.version)
    username = input('Please enter username to create: ')
    password = getpass(prompt='Please enter the password for the new user: ')
    password_verify = getpass(prompt='Enter password again to verify: ')
    if password != password_verify:
        print('Passwords do not match. Exiting.')
        exit(1)
    make_admin = False
    while True:
        input_admin = input('Should the new user have admin privileges? [y/n] ')
        if input_admin == 'y':
            make_admin = True
            break
        elif input_admin == 'n':
            make_admin = False
            break

    user = User()