# Path: app/lib/conf.py
# APP = meta.APP_NAME
# class MetaConf(object):
# class Config(object):
#     def __init__(self):
#     def resolveMacros(self):
#     def getConfRoot(self):
#     def getSnapPath(self):
#     def getConfPaths(self):
#     def __init__(self, **kwargs):
#     def load(self, conf_type, *file_path):
#     def get(self, section, key):
#     def set(self, section, key, value):
#     def show(self):
#     def save(self):
#     def envGet():
#     def envGet2(key):
#     def envSet(self, **kwargs):
#     def envShow(self):
#     def getConfig(self, file):
#     def parseConfig(file):
# 
# Path: app/__metadata__.py
# APP_NAME = 'LXDUI'
# APP_CLI_CMD = 'lxdui'
# VERSION = '2.2'
# GIT_URL = 'https://github.com/AdaptiveScale/lxdui.git'
# LXD_URL = 'http://localhost:8443'
# LICENSE = 'Apache 2.0'
# AUTHOR = 'AdaptiveScale, Inc.'
# AUTHOR_URL = 'http://www.adaptivescale.com'
# AUTHOR_EMAIL = 'info@adaptivescale.com'
# KEYWORDS = 'lxc lxc-containers lxd'
# IMAGE_HUB = 'http://hub.kuti.io'
# AUTO_LOAD_CONFIG = True
# DEFAULT_CONFIG_FORMAT = 'ini'


from app.lib import conf
from app import __metadata__ as meta
import os
import json
import hashlib
import logging
import bcrypt
        sha1_password = hashlib.sha1(password.encode('utf-8')).hexdigest()
        return sha1_password

    @classmethod
    def bcrypt_password(cls, password):
        hashed_password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()).decode('utf-8')
        return hashed_password

    def show(self):
        # retrieve just the user names
        counter = 0
        for user in self.users:
            username = user['username']
            counter += 1
            print('{}. {}'.format(counter, username))

    def add(self, username, password):
        # check if the user exists first
        for user in self.users:
            if user['username'] == username:
                print('User "{}" already exists.'.format(user['username']))
                # raise Exception('Duplicate user name')
                exit()

        data = self.users
        data.append({'username': username, 'password': self.bcrypt_password(password)})
        self.save(data)

    def delete(self, username):
        account, err = self.get(username)

# Path: app/lib/conf.py
# APP = meta.APP_NAME
# class MetaConf(object):
# class Config(object):
#     def __init__(self):
#     def resolveMacros(self):
#     def getConfRoot(self):
#     def getSnapPath(self):
#     def getConfPaths(self):
#     def __init__(self, **kwargs):
#     def load(self, conf_type, *file_path):
#     def get(self, section, key):
#     def set(self, section, key, value):
#     def show(self):
#     def save(self):
#     def envGet():
#     def envGet2(key):
#     def envSet(self, **kwargs):
#     def envShow(self):
#     def getConfig(self, file):
#     def parseConfig(file):
# 
# Path: app/__metadata__.py
# APP_NAME = 'LXDUI'
# APP_CLI_CMD = 'lxdui'
# VERSION = '2.2'
# GIT_URL = 'https://github.com/AdaptiveScale/lxdui.git'
# LXD_URL = 'http://localhost:8443'
# LICENSE = 'Apache 2.0'
# AUTHOR = 'AdaptiveScale, Inc.'
# AUTHOR_URL = 'http://www.adaptivescale.com'
# AUTHOR_EMAIL = 'info@adaptivescale.com'
# KEYWORDS = 'lxc lxc-containers lxd'
# IMAGE_HUB = 'http://hub.kuti.io'
# AUTO_LOAD_CONFIG = True
# DEFAULT_CONFIG_FORMAT = 'ini'


# Path: app/lib/auth.py
from app.lib import conf
from app import __metadata__ as meta
import os
import json
import hashlib
import logging
import bcrypt

        sha1_password = hashlib.sha1(password.encode('utf-8')).hexdigest()
        return sha1_password

    @classmethod
    def bcrypt_password(cls, password):
        hashed_password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()).decode('utf-8')
        return hashed_password

    def show(self):
        # retrieve just the user names
        counter = 0
        for user in self.users:
            username = user['username']
            counter += 1
            print('{}. {}'.format(counter, username))

    def add(self, username, password):
        # check if the user exists first
        for user in self.users:
            if user['username'] == username:
                print('User "{}" already exists.'.format(user['username']))
                # raise Exception('Duplicate user name')
                exit()

        data = self.users
        data.append({'username': username, 'password': self.bcrypt_password(password)})
        self.save(data)

    def delete(self, username):
        account, err = self.get(username)

        admin = conf.Config().get(meta.APP_NAME, '{}.admin.user'.format(meta.APP_NAME.lower()))