Exemple #1
0
    def __init__(self, id):
        '''Simple User class'''
        if not Configuration.loginRequired():
            # dummy account for when logon is not required.
            USERS = {"_dummy_": "_dummy_"}
        else:
            USERS = {}
        for user in db.getUsers():
            USERS[user['username']] = user['password']

        if not id in USERS:
            raise UserNotFoundError()
        self.id = id
        self.password = USERS[id]
Exemple #2
0
 def __init__(self, id):
     '''Simple User class'''
     if not Configuration.loginRequired():
         # dummy account for when logon is not required.
         USERS = {"_dummy_": "_dummy_"}
     else:
         USERS = {}
     for user in db.getUsers():
         USERS[user['username']] = user['password']
     
     if not id in USERS:
         raise UserNotFoundError()
     self.id = id
     self.password = USERS[id]
Exemple #3
0
class User(UserMixin):
    '''Simple User class'''
    if not Configuration.loginRequired():
        # dummy account for when logon is not required.
        USERS = {"_dummy_": "_dummy_"}
    else:
        USERS = {}
    for user in db.getUsers():
        USERS[user['username']] = user['password']

    def __init__(self, id):
        if not id in self.USERS:
            raise UserNotFoundError()
        self.id = id
        self.password = self.USERS[id]

    @classmethod
    def get(self_class, id):
        '''Return user instance of id, return None if not exist'''
        try:
            return self_class(id)
        except UserNotFoundError:
            return None