Updated token validation middleware