public IActionResult Index(MvcIdentityModel identity)
        {
            if (!ModelState.IsValid)
            {
                return(View("Registration", identity));
            }

            if (!UsernameAvailable(identity.Username))
            {
                ModelState.AddModelError("Username", "This username is already taken!");
                return(View("Registration", identity));
            }

            if (!EmailAvailable(identity.Email))
            {
                ModelState.AddModelError("Email", "This email is already in use!");
                return(View("Registration", identity));
            }

            var authIdentity = new AuthenticationIdentity()
            {
                Email             = identity.Email,
                NewAccount        = true,
                PendingActivation = true
            };

            identity.IpAddress = Request.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString();

            var activationToken = RandomData.String(16);

            var pendingActivation = new PendingActivationIdentity()
            {
                ActivationToken = activationToken,
                Identity        = identity
            };

            CacheStore.Create(activationToken, DateTime.UtcNow.AddHours(1), pendingActivation);

            SendGridHandler.SendRegistrationMail(identity, activationToken).Wait();

            return(RedirectToAction("Index", "Authentication", authIdentity));
        }