def _checkpassword(self, client, data, spam=False):
        """
        Check the password for match in database
        """

        password_match = False
        client_from_db = self._get_client_from_db(client.id)
        db_password = client_from_db.password
        self.debug('%s' % db_password)
        if db_password == '':
            return
        if spam:
            words = data.split()
            self.debug('Words are: %s' % words)
            for word in words:
                if db_password == hash_password(word):
                    password_match = True
                    break
        else:
            self.debug('%s %s' % (hash_password(data), db_password))
            if hash_password(data) == db_password:
                password_match = True

        if password_match:
            if spam:
                _newpass = ''.join([random.choice(string.ascii_letters) for i in xrange(6)])
                client.password = hash_password(_newpass)
                client.groupBits = client.var(self, 'login_groupbits').value
                client.save()
                self.debug('New password saved to %s, by B3 (spammed)' % client.name)
                client.message('OOOPS! Your new password is: %s' % _newpass)
            else:
                return True
Example #2
0
    def cmd_q3setpassword(self, data, client, cmd=None):
        """\
         - set a password for a client /password <new password>:[name]
        """
        _password = self._getpassword(client)
        _pdata = _password.split(':')
        if not _password:
            client.message('Usage in console: FIRST /password <new password>:[name] THEN !q3setpassword')
            return

        data = data.split()
        if len(data) > 0:
            client.message('Usage in console: FIRST /password <new password>:[name] THEN !q3setpassword')
        self.verbose(len(_pdata))
        if len(_pdata) > 1:
            sclient = self._adminPlugin.findClientPrompt(_pdata[1], client)
            if not sclient: return
            if client.maxLevel <= sclient.maxLevel and client.maxLevel < 100:
                client.message('You can only change passwords of yourself or lower level players.')
                return
        else:
            sclient = client
        self.debug(_pdata)
        sclient.password = hash_password(_pdata[0])
        if sclient.isvar(self, 'login_groupbits'):
            sclient.groupBits = sclient.var(self, 'login_groupbits').value
            sclient.message('You have been logged in by B3')
        sclient.save()
        self.debug('New password saved to %s, by %s' % (sclient.name, client.name))
        if client == sclient:
            client.message("your new password is saved, do not forget to /reset password")
        else:
            client.message("new password for %s saved, do not forget to /reset password" % sclient.name)
Example #3
0
    def cmd_setpassword(self, data, client, cmd=None):
        """
        <password> [<client>] - set a password for a client
        """
        if not data:
            client.message('Usage: %s%s <new password> [<client>]' % (cmd.prefix, cmd.command))
            return

        data = string.split(data)
        if len(data) > 1:
            sclient = self._adminPlugin.findClientPrompt(data[1], client)
            if not sclient:
                return
            if client.maxLevel <= sclient.maxLevel and client.maxLevel < 100:
                client.message('You can only change passwords of yourself or lower level players')
                return
        else:
            sclient = client

        sclient.password = hash_password(data[0])
        sclient.save()
        if client == sclient:
            client.message("Your new password has been saved")
        else:
            client.message("New password for %s saved" % sclient.name)
Example #4
0
    def cmd_setpassword(self, data, client, cmd=None):
        """
        <password> [<client>] - set a password for a client
        """
        if not data:
            client.message('Usage: %s%s <new password> [<client>]' %
                           (cmd.prefix, cmd.command))
            return

        data = string.split(data)
        if len(data) > 1:
            sclient = self._adminPlugin.findClientPrompt(data[1], client)
            if not sclient:
                return
            if client.maxLevel <= sclient.maxLevel and client.maxLevel < 100:
                client.message(
                    'You can only change passwords of yourself or lower level players'
                )
                return
        else:
            sclient = client

        sclient.password = hash_password(data[0])
        sclient.save()
        if client == sclient:
            client.message("Your new password has been saved")
        else:
            client.message("New password for %s saved" % sclient.name)
Example #5
0
    def cmd_login(self, data, client, cmd=None):
        """
        <password> - login a privileged user to his full capabilities
        """
        if client.isvar(self, 'loggedin'):
            client.message('You are already logged in')
            return

        if not client.isvar(self, 'login_groupbits'):
            client.message('You do not need to log in')
            return

        if data:
            digest = hash_password(data)
            client_from_db = self._get_client_from_db(client.id)
            if digest == client_from_db.password:
                client.setvar(self, 'loggedin', 1)
                client.groupBits = client.var(self, 'login_groupbits').value
                client.message('You are successfully logged in')
            else:
                client.message('^1***Access denied***^7')
        else:
            message = 'Usage (via console): %s %s !login yourpassword' % (
                self._pmcomm, client.cid)
            client.message(message)
Example #6
0
    def cmd_login(self, data, client, cmd=None):
        """\
        <password> - login a privileged user to his full capabilities
        """
        if client.isvar(self, "loggedin"):
            client.message("You are already logged in.")
            return

        if not client.isvar(self, "login_groupbits"):
            client.message("You do not need to log in.")
            return

        if data:
            digest = hash_password(data)
            client_from_db = self._get_client_from_db(client.id)
            if digest == client_from_db.password:
                client.setvar(self, "loggedin", 1)
                client.groupBits = client.var(self, "login_groupbits").value
                client.message("You are successfully logged in.")
                return
            else:
                client.message("^1***Access denied***^7")
                return
        else:
            message = "Usage (via console): %s %s !login yourpassword" % (self._pmcomm, client.cid)
            client.message(message)
            return
Example #7
0
 def _checkpassword(self, client, data, spam=False):
     """
     Check the password for match in database
     """
     data = data.split()
     if spam:
         digest = hash_password(data[1])
     else:
         digest = hash_password(data[0])
     client_from_db = self._get_client_from_db(client.id)
     if digest == client_from_db.password:
         if spam:
             _newpass = ''.join([random.choice(string.ascii_letters) for i in xrange(6)])
             client.password = hash_password(_newpass)
             client.save()
             self.debug('New password saved to %s, by B3 (spammed)' % client.name)
             client.message('OOOPS! Your new password is: %s' % _newpass)
         else:
             return True