Skip to content

Commit

Permalink
注销用户重新登录的功能
Browse files Browse the repository at this point in the history
  • Loading branch information
kitakamiooi committed Dec 12, 2015
1 parent 84882df commit ffc62e0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
16 changes: 14 additions & 2 deletions handlers/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,17 @@ async def poi(self, request):
del session['world_ip']
return aiohttp.web.HTTPFound('/')

def logout(self):
pass
async def logout(self, request):
""" 注销已登录的用户。
清除所有的session,返回首页。
:return: aiohttp.web.HTTPFound
"""
session = await get_session(request)
if 'api_token' in session:
del session['api_token']
if 'api_starttime' in session:
del session['api_starttime']
if 'world_ip' in session:
del session['world_ip']
return aiohttp.web.HTTPFound('/')
1 change: 1 addition & 0 deletions ooi.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def main():
app.router.add_route('GET', '/kcv', frontend.kcv)
app.router.add_route('GET', '/flash', frontend.flash)
app.router.add_route('GET', '/poi', frontend.poi)
app.router.add_route('GET', '/logout', frontend.logout)
app.router.add_route('GET', '/kcsapi/{action:.+}', api.api)
app.router.add_route('POST', '/kcsapi/{action:.+}', api.api)
app.router.add_route('GET', '/kcs/resources/image/world/{server:[\d_]+}{size:l|s}.png', api.world_image)
Expand Down
4 changes: 4 additions & 0 deletions static/css/ooi.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ html, body, h1, h2, h3, h4, h5, h6 {

#ooi-footer {
margin-top: 15px;
}

#ooi-game #externalswf {
margin: 0 auto 15px auto;
}
1 change: 1 addition & 0 deletions templates/normal.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
{% block content -%}
<div id="ooi-game" class="uk-width-1-1 uk-text-center">
<embed id="externalswf" width="800" height="480" wmode="opaque" quality="high" bgcolor="#000000" allowscriptaccess="always" base="{{ scheme }}://{{ host }}/kcs/" type="application/x-shockwave-flash" src="{{ scheme }}://{{ host }}/kcs/mainD2.swf?api_token={{ token }}&amp;api_starttime={{ starttime }}&amp;world_ip={{ world_ip }}" style="display: block !important;"></embed>
<a href="/logout" class="uk-button uk-button-primary">重新登录</a>
</div>
{%- endblock %}

0 comments on commit ffc62e0

Please sign in to comment.