Merge branch 'develop' into charlist

This commit is contained in:
Johnny 2018-10-30 01:13:36 +00:00
commit c9b7c174ec
9 changed files with 65 additions and 78 deletions

View file

@ -15,15 +15,16 @@ class SharedLoginMiddleware(object):
# Code to be executed for each request before
# the view (and later middleware) are called.
# Synchronize credentials between webclient and website
# Must be performed *before* rendering the view (issue #1723)
self.make_shared_login(request)
# Process view
response = self.get_response(request)
# Code to be executed for each request/response after
# the view is called.
# Synchronize credentials
self.make_shared_login(request)
# Return processed view
return response

View file

@ -102,7 +102,7 @@ An "emitter" object must have a function
return;
}
this.connection.connect();
log('Evenna reconnecting.')
log('Evennia reconnecting.')
},
// Returns true if the connection is open.

View file

@ -12,52 +12,13 @@ from evennia.accounts.models import AccountDB
from evennia.utils import logger
def _shared_login(request):
"""
Handle the shared login between website and webclient.
"""
csession = request.session
account = request.user
# these can have 3 values:
# None - previously unused (auto-login)
# False - actively logged out (don't auto-login)
# <uid> - logged in User/Account id
website_uid = csession.get("website_authenticated_uid", None)
webclient_uid = csession.get("webclient_authenticated_uid", None)
# check if user has authenticated to website
if not csession.session_key:
# this is necessary to build the sessid key
csession.save()
if webclient_uid:
# The webclient has previously registered a login to this browser_session
if not account.is_authenticated() and not website_uid:
try:
account = AccountDB.objects.get(id=webclient_uid)
except AccountDB.DoesNotExist:
# this can happen e.g. for guest accounts or deletions
csession["website_authenticated_uid"] = False
csession["webclient_authenticated_uid"] = False
return
try:
# calls our custom authenticate in web/utils/backends.py
account = authenticate(autologin=account)
login(request, account)
csession["website_authenticated_uid"] = webclient_uid
except AttributeError:
logger.log_trace()
def webclient(request):
"""
Webclient page template loading.
"""
# handle webclient-website shared login
_shared_login(request)
# auto-login is now handled by evennia.web.utils.middleware
# make sure to store the browser session's hash so the webclient can get to it!
pagevars = {'browser_sessid': request.session.session_key}

View file

@ -80,7 +80,7 @@ folder and edit it to add/remove links to the menu.
</li>
{% else %}
<li>
<a class="nav-link" href="{% url 'login' %}">Log In</a>
<a class="nav-link" href="{% url 'login' %}?next={{ request.path }}">Log In</a>
</li>
<li>
<a class="nav-link" href="{% url 'register' %}">Register</a>

View file

@ -54,7 +54,7 @@
<div class="col-lg-3 col-sm-12">
{% if user.is_staff %}
<!-- admin button -->
<a class="btn btn-info btn-block mb-3" href="/admin/help/helpentry/add/">Admin</a>
<a class="btn btn-info btn-block mb-3" href="/admin/help/helpentry/">Admin</a>
<!-- end admin button -->
<hr />
{% endif %}

View file

@ -52,7 +52,7 @@
<div class="row">
<div class="col-12 col-md-4 mb-3">
<div class="card">
<h4 class="card-header">Accounts</h4>
<h4 class="card-header text-center">Accounts</h4>
<div class="card-body">
<p>

View file

@ -25,6 +25,10 @@ Forgot Password - Reset Link Sent
<p>Please allow up to to a few hours for the email to transmit, and be
sure to check your spam folder if it doesn't show up in a timely manner.</p>
<hr />
<p><a href="{% url 'index' %}">Click here</a> to return to the main page.</p>
{% endif %}
</div>
</div>

View file

@ -34,7 +34,7 @@ Forgot Password
<hr />
<div class="form-group">
<input class="form-control btn btn-outline-secondary" type="submit" value="Login" />
<input class="form-control btn btn-outline-secondary" type="submit" value="Submit" />
<input type="hidden" name="next" value="{{ next }}" />
</div>
</form>