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 = newmd5(data).hexdigest() if digest == client.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
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 = newmd5(data).hexdigest() if digest == client.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
def cmd_setpassword(self, data, client, cmd=None): """\ <password> [<name>] - set a password for a client """ 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 = newmd5(data[0]).hexdigest() self.console.storage.query(QueryBuilder(self.console.storage.db).UpdateQuery( { 'password' : sclient.password }, 'clients', { 'id' : sclient.id } )) return
def cmd_setpassword(self, data, client, cmd=None): """\ <password> [<name>] - set a password for a client """ 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 = newmd5(data[0]).hexdigest() self.console.storage.query( QueryBuilder(self.console.storage.db).UpdateQuery( {'password': sclient.password}, 'clients', {'id': sclient.id})) return
def generatePasswordHash(salt, password): m = newmd5() m.update(salt) m.update(password) return m.digest()