private ClaimsPrincipal GeneratePrincipal(User user, AccessToken accessToken)
        {
            if (user.Roles == null)
            {
                user.Roles = new List <UserRole>();
            }

            var roles = user.Roles.Select(r => r.Type.ToString()).ToArray();

            var identity = new GenericIdentity(user.Name, SecurityModule.AUTH_TYPE);

            identity.TryRemoveClaim(identity.Claims.FirstOrDefault());

            var principal = new GenericPrincipal(identity, roles);

            Claim token   = new Claim(ClaimTypes.Authentication, accessToken.Token, "Info", SecurityModule.AUTH_TYPE, SecurityModule.AUTH_TYPE, identity);
            Claim userKey = new Claim(ClaimTypes.NameIdentifier, user.UserKey.ToString(), "Info", SecurityModule.AUTH_TYPE, SecurityModule.AUTH_TYPE, identity);
            Claim email   = new Claim(ClaimTypes.Email, user.Contacts.Email, "Info", SecurityModule.AUTH_TYPE, SecurityModule.AUTH_TYPE, identity);

            identity.AddClaim(token);
            identity.AddClaim(userKey);
            identity.AddClaim(email);

            user.Roles.ForEach(role =>
            {
                Claim tempRole = new Claim(ClaimTypes.Role, role.Type.ToString(), "Role", SecurityModule.AUTH_TYPE, SecurityModule.AUTH_TYPE, identity);

                if (role.Keys != null)
                {
                    role.Keys.ForEach(key =>
                    {
                        tempRole.Properties.Add(new KeyValuePair <string, string>(key, role.Type.ToString()));
                    });
                    identity.AddClaim(tempRole);
                }
            });

            return(principal);
        }