Fix logout (fixes #146)
This commit is contained in:
parent
f5be2b20f8
commit
bc17c72fdb
1 changed files with 11 additions and 1 deletions
|
@ -10,7 +10,7 @@ from oic.oic import Client
|
||||||
from oic.oic.message import AuthorizationResponse, RegistrationResponse
|
from oic.oic.message import AuthorizationResponse, RegistrationResponse
|
||||||
from oic.utils.authn.client import CLIENT_AUTHN_METHOD
|
from oic.utils.authn.client import CLIENT_AUTHN_METHOD
|
||||||
|
|
||||||
from obs.api.app import auth
|
from obs.api.app import auth, api
|
||||||
from obs.api.db import User
|
from obs.api.db import User
|
||||||
|
|
||||||
from sanic.response import json, redirect
|
from sanic.response import json, redirect
|
||||||
|
@ -145,3 +145,13 @@ async def login_redirect(req):
|
||||||
|
|
||||||
next_ = session.pop("next", "/") or "/"
|
next_ = session.pop("next", "/") or "/"
|
||||||
return redirect(next_)
|
return redirect(next_)
|
||||||
|
|
||||||
|
|
||||||
|
@api.route("/logout")
|
||||||
|
async def login(req):
|
||||||
|
session = req.ctx.session
|
||||||
|
if "user_id" in session:
|
||||||
|
del session["user_id"]
|
||||||
|
|
||||||
|
next_url = req.ctx.get_single_arg("next", default=None) or "/"
|
||||||
|
return redirect(next_url)
|
||||||
|
|
Loading…
Add table
Reference in a new issue