Hello, I have this code and I need to control all access to the website if the user is not authenticated and redirect to login, that works with '/test' or any route that does not exist like shop.
The question is How i redirect all routes?
def user_is_authenticated(f):
@wraps(f)
def decorated_function(*args, **kwargs):
if not request.session.uid:
return request.redirect('/web/login')
return f(*args, **kwargs)
return decorated_function
class Testing(http.Controller):
@http.route('/test', auth='public', website=True)
@user_is_authenticated
def index(self, **kw):
return request.env['ir.http']._dispatch()