Make IDLE_TIMEOUT avoidable with account-lock.

Resolves #701. Check the Account-lock 'no_idle_disconnect before kicking an idle
session. This also means superusers will never be kicked. Move the
idle task to the Server to avoid lock imports in Portal. Make the
'lock' command also able to target Accounts. Also some other fixes.
This commit is contained in:
Griatch 2017-08-20 23:11:33 +02:00
parent cdac9678b9
commit 8a2e362b7c
11 changed files with 63 additions and 52 deletions

View file

@ -657,10 +657,12 @@ class CmdQuit(COMMAND_DEFAULT_CLASS):
if 'all' in self.switches:
account.msg("|RQuitting|n all sessions. Hope to see you soon again.", session=self.session)
reason = "quit/all"
for session in account.sessions.all():
account.disconnect_session_from_account(session)
account.disconnect_session_from_account(session, reason)
else:
nsess = len(account.sessions.all())
reason = "quit"
if nsess == 2:
account.msg("|RQuitting|n. One session is still connected.", session=self.session)
elif nsess > 2:
@ -668,7 +670,7 @@ class CmdQuit(COMMAND_DEFAULT_CLASS):
else:
# we are quitting the last available session
account.msg("|RQuitting|n. Hope to see you again, soon.", session=self.session)
account.disconnect_session_from_account(self.session)
account.disconnect_session_from_account(self.session, reason)
class CmdColorTest(COMMAND_DEFAULT_CLASS):

View file

@ -1735,9 +1735,9 @@ class CmdLock(ObjManipCommand):
assign a lock definition to an object
Usage:
@lock <object>[ = <lockstring>]
@lock <object or *account>[ = <lockstring>]
or
@lock[/switch] <object>/<access_type>
@lock[/switch] <object or *account>/<access_type>
Switch:
del - delete given access type
@ -1779,16 +1779,19 @@ class CmdLock(ObjManipCommand):
if '/' in self.lhs:
# call on the form @lock obj/access_type
objname, access_type = [p.strip() for p in self.lhs.split('/', 1)]
obj = caller.search(objname)
if not obj:
if objname.startswith("*"):
obj = caller.search_account(objname.lstrip('*'))
if not obj:
obj = caller.search(objname)
if not obj:
return
if not (obj.access(caller, 'control') or obj.access(caller, "edit")):
caller.msg("You are not allowed to do that.")
return
lockdef = obj.locks.get(access_type)
string = ""
if lockdef:
if 'del' in self.switches:
if not (obj.access(caller, 'control') or obj.access(caller, "edit")):
caller.msg("You are not allowed to do that.")
return
obj.locks.delete(access_type)
string = "deleted lock %s" % lockdef
else:
@ -1808,9 +1811,12 @@ class CmdLock(ObjManipCommand):
return
objname, lockdef = self.lhs, self.rhs
obj = caller.search(objname)
if not obj:
return
if objname.startswith("*"):
obj = caller.search_account(objname.lstrip('*'))
if not obj:
obj = caller.search(objname)
if not obj:
return
if not (obj.access(caller, 'control') or obj.access(caller, "edit")):
caller.msg("You are not allowed to do that.")
return