<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def login_required(func, permission=None):
 """ decorate with this function in order to require a valid token for any view If no token is present you will be sent to a login page """

    @wraps(func)
    def decorated_function(*args, **kwargs):
        if not check_token():
            return login()
        elif not nago.core.has_access(session.get('token')):
            return http403()
        return func(*args, **kwargs)
    return decorated_function