コード例 #1
0
 def requestAvatarId(self, cred):  # pylint: disable=no-self-use
     """get user id from database"""
     cred.username = cred.username.decode('utf-8')
     args = cred.username.split(SERVERMARK)
     if len(args) > 1:
         if args[0] == 'adduser':
             cred.username = args[1]
             password = args[2]
             query = Query(
                 'insert or ignore into player(name,password) values(?,?)',
                 (cred.username, password))
         elif args[1] == 'deluser':
             pass
     query = Query('select id, password from player where name=?',
                   (cred.username, ))
     if not len(query.records):
         template = 'Wrong username: %1'
         if Debug.connections:
             logDebug(i18n(template, cred.username))
         return fail(
             credError.UnauthorizedLogin(srvMessage(template,
                                                    cred.username)))
     userid, password = query.records[0]
     defer1 = maybeDeferred(cred.checkPassword, password.encode('utf-8'))
     defer1.addCallback(DBPasswordChecker._checkedPassword, userid)
     return defer1
コード例 #2
0
 def _checkedPassword(matched, userid):
     """after the password has been checked"""
     if not matched:
         return fail(
             credError.UnauthorizedLogin(srvMessage(
                 i18nE('Wrong password'))))
     return userid