def core__manage_superuser_session(permission = nil)
      decoded_token = core__decode_token(session[:lato_core__superuser_session_token])

      if decoded_token
        @core__current_superuser = LatoCore::Superuser.find_by(id: decoded_token[:superuser_id])
        unless @core__current_superuser
          core__destroy_superuser_session
          redirect_to lato_core.login_path
        end

        if permission && @core__current_superuser.permission < permission
          flash[:danger] = 'PERMISSION ERROR'
          redirect_to lato_core.root_path
        end
      else
        redirect_to lato_core.login_path
      end
    end
def core__manage_superuser_session(permission = nil)
      decoded_token = core__decode_token(session[:lato_core__superuser_session_token])

      if decoded_token
        @core__current_superuser = LatoCore::Superuser.find_by(id: decoded_token[:superuser_id])
        unless @core__current_superuser
          core__destroy_superuser_session
          redirect_to lato_core.login_path
        end

        if permission && @core__current_superuser.permission < permission
          flash[:danger] = 'PERMISSION ERROR'
          redirect_to lato_core.root_path
        end
      else
        redirect_to lato_core.login_path
      end
    end
This function check the session for a superuser and set the variable @core__current_superuser.
 If session is not valid the user should be redirect to login path.