Skip to content

Commit

Permalink
new removable prefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Jan 13, 2016
1 parent 8104b4a commit bc48abb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
25 changes: 17 additions & 8 deletions src/appier_extras/parts/admin/models/account.py
Expand Up @@ -54,6 +54,15 @@ class Account(base.Base):
USER_TYPE : "user"
}

PREFIXES = (
"fb.",
"tw.",
"gg.",
"gh.",
"live.",
"params."
)

username = appier.field(
index = True,
default = True
Expand Down Expand Up @@ -309,21 +318,21 @@ def is_encrypted(cls, password):
return password.count(":") > 0

@classmethod
def _unset_session(cls):
def _unset_session(cls, prefixes = None):
prefixes = prefixes or cls.PREFIXES
session = appier.get_session()
if "username" in session: del session["username"]
if "name" in session: del session["name"]
if "email" in session: del session["email"]
if "type" in session: del session["type"]
if "tokens" in session: del session["tokens"]
if "params" in session: del session["params"]
if "fb.access_token" in session: del session["fb.access_token"]
if "tw.oauth_token" in session: del session["tw.oauth_token"]
if "tw.oauth_token_secret" in session: del session["tw.oauth_token_secret"]
if "tw.oauth_temporary" in session: del session["tw.oauth_temporary"]
if "gg.access_token" in session: del session["gg.access_token"]
if "gh.access_token" in session: del session["gh.access_token"]
if "live.access_token" in session: del session["live.access_token"]
for key in appier.legacy.keys(session):
for prefix in prefixes:
removable = key.startswith(prefix)
if removable: break
if not removable: continue
del session[key]

def pre_save(self):
base.Base.pre_save(self)
Expand Down
2 changes: 1 addition & 1 deletion src/appier_extras/parts/admin/part.py
Expand Up @@ -387,7 +387,7 @@ def show_session(self, sid):
return self.template(
"session.html.tpl",
section = "status",
session = self.request.session_c.get_s(sid)
session_s = self.request.session_c.get_s(sid)
)

@appier.ensure(token = "admin")
Expand Down
@@ -1,6 +1,6 @@
{% extends "admin/admin.fluid.html.tpl" %}
{% block title %}{{ session.sid }}{% endblock %}
{% block name %}{{ session.sid }}{% endblock %}
{% block title %}{{ session_s.sid }}{% endblock %}
{% block name %}{{ session_s.sid }}{% endblock %}
{% block style %}no-padding{% endblock %}
{% block content %}
<table class="filter" data-no_input="1">
Expand All @@ -11,8 +11,8 @@
</tr>
</thead>
<tbody class="filter-contents">
{% for key in session.sorted() %}
{% set value = session[key] %}
{% for key in session_s.sorted() %}
{% set value = session_s[key] %}
<tr class="table-row">
<td class="text-left">
<strong>{{ key }}</strong>
Expand Down
Expand Up @@ -18,7 +18,7 @@
<tr class="table-row">
<td class="text-left">
<strong>
<a href="{{ url_for('admin.show_session', sid = session.sid) }}">{{ session.sid }}</a>
<a href="{{ url_for('admin.show_session', sid = session.sid) }}">{{ session.sid }}</a>
</strong>
</td>
<td class="text-left">{{ date_time(session.create, format = "%d %b %Y %H:%M:%S") }}</td>
Expand Down

0 comments on commit bc48abb

Please sign in to comment.