.BANCHO. Add more privileges check through direct privilege value

This commit is contained in:
Nyo
2016-11-15 19:27:21 +01:00
parent ef940771d8
commit 7b06f2921e
5 changed files with 22 additions and 11 deletions

View File

@@ -11,14 +11,17 @@ def handle(userToken, packetData):
userID = userToken.userID
username = userToken.username
# Update privileges
userToken.updatePrivileges()
# Make sure we are not banned
if userUtils.isBanned(userID):
if userUtils.isBanned(priv=userToken.privileges):
userToken.enqueue(serverPackets.loginBanned())
return
# Send restricted message if needed
if not userToken.restricted:
if userUtils.isRestricted(userID):
if userUtils.isRestricted(priv=userToken.privileges):
userToken.setRestricted()
# Change action packet

View File

@@ -64,9 +64,9 @@ def handle(tornadoRequest):
# Make sure we are not banned or locked
priv = userUtils.getPrivileges(userID)
if userUtils.isBanned(userID) == True and priv & privileges.USER_PENDING_VERIFICATION == 0:
if userUtils.isBanned(priv=priv) == True and not userUtils.isPending(priv=priv):
raise exceptions.loginBannedException()
if userUtils.isLocked(userID) == True and priv & privileges.USER_PENDING_VERIFICATION == 0:
if userUtils.isLocked(priv=priv) == True and not userUtils.isPending(priv=priv):
raise exceptions.loginLockedException()
# 2FA check
@@ -195,6 +195,10 @@ def handle(tornadoRequest):
location = locationHelper.getLocation(requestIP)
countryLetters = locationHelper.getCountry(requestIP)
country = countryHelper.getCountryID(countryLetters)
# Set country in db if user has no country (first bancho login)
if userUtils.getCountry(userID) == "XX":
userUtils.setCountry(userID, countryLetters)
else:
# Set location to 0,0 and get country from db
log.warning("Location skipped")
@@ -206,10 +210,6 @@ def handle(tornadoRequest):
responseToken.setLocation(location)
responseToken.setCountry(country)
# Set country in db if user has no country (first bancho login)
if userUtils.getCountry(userID) == "XX":
userUtils.setCountry(userID, countryLetters)
# Send to everyone our userpanel if we are not restricted or tournament
if not responseToken.restricted:
glob.streams.broadcast("main", serverPackets.userPanel(userID))