Esempio n. 1
0
def isPassCorrect(userName: str, password: str, client: Mongo):
    block = client.get_doc({"username": userName}, getenv('USER_COLLECTION'))

    if block == None:
        return False

    if block.get('password') == password:
        return True
    else:
        return False
def getNcloudConfig(DB: Mongo):
    data: dict = DB.get_doc({}, getenv('ADMIN_COLLECTION'))
    if data == None:
        return None

    return {
        "addall_inNewHosts": data.get('addall_inNewHosts'),
        "autoStartSrvr": data.get('autoStartSrvr'),
        "allowRegistration": data.get('allowRegistration'),
        "pendingNewUser": data.get('pendingNewUser')
    }
Esempio n. 3
0
def rejectReq(userName: str, client: Mongo):
    user: dict = client.get_doc({"username": userName},
                                getenv('PENDING_USER_COLLECTION'))

    if user == None:
        return "Username doesn't exists", False
    else:
        ret, msg = client.remove({"username": userName},
                                 getenv('PENDING_USER_COLLECTION'))
        if ret == True:
            return "User removed from the pending list", True
        else:
            return "Error ocurred while removing user from the pending list", False
Esempio n. 4
0
def approveReq(userName: str, client: Mongo):
    user: dict = client.get_doc({"username": userName},
                                getenv('PENDING_USER_COLLECTION'))

    if user == None:
        return "Username doesn't exists", False
    else:
        x = user.copy()
        p_id = x.pop('_id')
        if client.isDocExists({"username": x.get('username')},
                              getenv('USER_COLLECTION')):
            return "User is already exists in main list", False
        u_id = client.insert([x], getenv('USER_COLLECTION'))
        if u_id == None:
            return "Error Occured", False
        else:
            client.remove_ById(p_id, getenv('PENDING_USER_COLLECTION'))
            return "User added to main list", True