Commit a4291f50 authored by Pierre-Elliott Bécue's avatar Pierre-Elliott Bécue

[wiki/auth] Behavior plus adapté en cas de login utilisateur.

parent 613a1353
...@@ -36,6 +36,14 @@ class AnonymousAuth(BaseAuth): ...@@ -36,6 +36,14 @@ class AnonymousAuth(BaseAuth):
raise NotImplementedError raise NotImplementedError
def request(self, request, user_obj, **kw): def request(self, request, user_obj, **kw):
action = request.args.get("action", "")
# Si l'utilisateur est en train de se connecter
# On droppe la pseudo connexion anonyme, si elle
# existe bien.
if action == 'login':
if user_obj:
user_obj.valid = False
return user_obj, True
# authenticated user # authenticated user
if user_obj and user_obj.valid and user_obj.auth_method != self.name and user_obj.name != self.auth_username: if user_obj and user_obj.valid and user_obj.auth_method != self.name and user_obj.name != self.auth_username:
...@@ -59,7 +67,6 @@ class AnonymousAuth(BaseAuth): ...@@ -59,7 +67,6 @@ class AnonymousAuth(BaseAuth):
else: else:
u = user_obj u = user_obj
action = request.args.get("action", "")
p = urlparse.urlparse(request.url) p = urlparse.urlparse(request.url)
# Impossible to edit preferences # Impossible to edit preferences
if u and u.valid and action == "userprefs": if u and u.valid and action == "userprefs":
......
...@@ -33,7 +33,7 @@ class PublicCategories(AnonymousAuth): ...@@ -33,7 +33,7 @@ class PublicCategories(AnonymousAuth):
def can_view(self, request): def can_view(self, request):
p = urlparse.urlparse(request.url) p = urlparse.urlparse(request.url)
if p.path[1:] == "": if p.path[1:] == "":
return False return True
if request.page is not None: if request.page is not None:
sys.stderr.write("Getting page from cache") sys.stderr.write("Getting page from cache")
page = request.page page = request.page
...@@ -70,7 +70,8 @@ class PublicCategories(AnonymousAuth): ...@@ -70,7 +70,8 @@ class PublicCategories(AnonymousAuth):
p = urlparse.urlparse(request.url) p = urlparse.urlparse(request.url)
url = urlparse.urlunparse(('https', p.netloc, p.path, "", "", "")) url = urlparse.urlunparse(('https', p.netloc, p.path, "", "", ""))
action = request.args.get("action", "") action = request.args.get("action", "")
if action != "deny": # pas de redirection si action est déjà deny ou que l'utilisateur se connecte
if action not in [ "deny", "login"]:
request.http_redirect(url + "?action=deny") request.http_redirect(url + "?action=deny")
return user_obj, cont return user_obj, cont
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment