private ClaimsIdentity CreateClaimsIdentity(Token token)
        {
            var claims = new Claim[]
            {
                new Claim(ClaimTypes.NameIdentifier, token.Username),
                new Claim(ClaimTypes.Name, token.Username),
                new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", token.Username),
                new Claim("urn:Custom:UserType", "AnonymousUser")
            };

            return new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie);
        }
 public ActionResult TokenLogin(Token token)
 {
     token = GetTokenFromDatabase(token.Value);
     if (token != null)
     {
         AuthenticateWithToken(token);
         return RedirectToAction("Index", "Home");
     }
     return RedirectToAction("Login");
 }
        private void AuthenticateWithToken(Token token)
        {
            ClaimsIdentity identity = CreateClaimsIdentity(token);

            Microsoft.Owin.Security.IAuthenticationManager authenticationManager =
                System.Web.HttpContext.Current.GetOwinContext().Authentication;

            authenticationManager.SignIn(identity);
        }