utils: Ajout du décorateur @guest_only
This commit is contained in:
parent
8bf825f9ea
commit
16756f639f
|
@ -36,3 +36,15 @@ def priv_required(*perms):
|
|||
return func(*args, **kwargs)
|
||||
return wrapped
|
||||
return decorated_view
|
||||
|
||||
|
||||
def guest_only(func):
|
||||
"""
|
||||
Opposite decorator of @login_required
|
||||
"""
|
||||
@wraps(func)
|
||||
def wrapped(*args, **kwargs):
|
||||
if current_user.is_authenticated:
|
||||
abort(404)
|
||||
return func(*args, **kwargs)
|
||||
return wrapped
|
||||
|
|
Loading…
Reference in New Issue