Small fix on the isCsrfTokenValid function. Base64 encode was missing.