Add smarter shared login on website/webclient. Resolves #1063.
This makes it so that logging into the website will auto-log you into the webclient and vice-versa when you refresh the page. But if you log out of the web client will have to manually log in again. If you log out of the website and reload the webclient page you will have to log back into the client too (this is because logging out of the website flushes the browser session, it doesn't seem worth the effort to override django.auth in this).
This commit is contained in:
parent
0ac190b6ea
commit
cdac9678b9
7 changed files with 20 additions and 67 deletions
|
|
@ -137,32 +137,6 @@ def default(session, cmdname, *args, **kwargs):
|
|||
log_err(err)
|
||||
|
||||
|
||||
def browser_sessid(session, *args, **kwargs):
|
||||
"""
|
||||
This is a utility function for the webclient (only) to communicate its
|
||||
current browser session hash. This is important in order to link
|
||||
the browser session to the evennia session. Only the very first
|
||||
storage request will be accepted, the following ones will be ignored.
|
||||
|
||||
Args:
|
||||
browserid (str): Browser session hash
|
||||
|
||||
"""
|
||||
if not session.browserid:
|
||||
print "stored browserid:", session, args[0]
|
||||
session.browserid = args[0]
|
||||
if not session.logged_in:
|
||||
# automatic log in if the django browser session already authenticated.
|
||||
browsersession = BrowserSessionStore(session_key=args[0])
|
||||
uid = browsersession.get("logged_in", None)
|
||||
if uid:
|
||||
try:
|
||||
account = AccountDB.objects.get(pk=uid)
|
||||
except Exception:
|
||||
return
|
||||
session.sessionhandler.login(session, account)
|
||||
|
||||
|
||||
def client_options(session, *args, **kwargs):
|
||||
"""
|
||||
This allows the client an OOB way to inform us about its name and capabilities.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue