Skip to content

Commit

Permalink
Log out client side instead of using server request
Browse files Browse the repository at this point in the history
  • Loading branch information
BBaoVanC committed Nov 5, 2023
1 parent 23ec804 commit 069dfc4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
6 changes: 5 additions & 1 deletion isso/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,8 @@ function send_edit(com_id, hash, isso_host_script) {
edit(com_id, hash, author, email, website, comment, isso_host_script);
stop_edit(com_id, true);
}

function log_out() {
// Delete cookie
document.cookie = "admin-session=; Max-Age=0; domain=" + window.location.hostname + "; path=/";
window.location.reload();
}
2 changes: 1 addition & 1 deletion isso/templates/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h2>Administration</h2>
</a>
</div>
</header>
<a class="logout" href="/logout">Log Out</a>
<a id="logout" class="logout label" onClick="javascript:log_out()">Log Out</a>
</div>
<div class="outer">
<div class="filters">
Expand Down
7 changes: 0 additions & 7 deletions isso/views/comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ class API(object):
('preview', ('POST', '/preview')),
('config', ('GET', '/config')),
('login', ('POST', '/login/')),
('logout', ('GET', '/logout')),
('admin', ('GET', '/admin/'))
]

Expand Down Expand Up @@ -1354,12 +1353,6 @@ def login(self, env, req):
isso_host_script = self.isso.conf.get("server", "public-endpoint") or local.host
return render_template('login.html', isso_host_script=isso_host_script)

def logout(self, env, req):
response = redirect("/admin")
response.headers.add("Set-Cookie", "admin-session=none; path=/; max-age=0;")
response.headers.add("X-Set-Cookie", "isso-admin-session=none; path=/; max-age=0;")
return response

"""
@api {get} /admin/ Admin interface
@apiGroup Admin
Expand Down

0 comments on commit 069dfc4

Please sign in to comment.