Esempio n. 1
0
    def remove_account(self, username):
        if username not in self.__auth:
            raise AuthManagerError('Username not known', username)
        elif username == component.get('RPCServer').get_session_user():
            raise AuthManagerError(
                'You cannot delete your own account while logged in!',
                username)

        del self.__auth[username]
        self.write_auth_file()
        return True
Esempio n. 2
0
 def create_account(self, username, password, authlevel):
     if username in self.__auth:
         raise AuthManagerError('Username in use.', username)
     if authlevel not in AUTH_LEVELS_MAPPING:
         raise AuthManagerError('Invalid auth level: %s' % authlevel)
     try:
         self.__auth[username] = Account(username, password,
                                         AUTH_LEVELS_MAPPING[authlevel])
         self.write_auth_file()
         return True
     except Exception as ex:
         log.exception(ex)
         raise ex
Esempio n. 3
0
 def update_account(self, username, password, authlevel):
     if username not in self.__auth:
         raise AuthManagerError('Username not known', username)
     if authlevel not in AUTH_LEVELS_MAPPING:
         raise AuthManagerError('Invalid auth level: %s' % authlevel)
     try:
         self.__auth[username].username = username
         self.__auth[username].password = password
         self.__auth[username].authlevel = AUTH_LEVELS_MAPPING[authlevel]
         self.write_auth_file()
         return True
     except Exception as ex:
         log.exception(ex)
         raise ex