public async Task CreateAsync(CassandraRole role)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.CreateRoleAsync(role);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
示例#2
0
 public async Task RemoveClaimAsync(CassandraUser user, Claim claim)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.DeleteClaimHandleByUserIdTypeAndValueAsync(user.Id, claim.Type, claim.Value);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
示例#3
0
 public async Task RemoveFromRoleAsync(CassandraUser user, string roleName)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.RemoveFromRoleAsync(user.Id, roleName);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
示例#4
0
        public async Task <bool> IsInRoleAsync(CassandraUser user, string roleName)
        {
            var result = await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
                async() =>
            {
                await ResilientSessionContainer.EstablishSessionAsync();
                return(await ResilientSessionContainer.ResilientSession.IsUserInRoleAsync(user.Id, roleName));
            },
                async (ex) => ResilientSessionContainer.HandleCassandraException <bool>(ex));

            return(result);
        }
示例#5
0
        public async Task <IList <string> > GetRolesAsync(CassandraUser user)
        {
            var resultList = await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
                async() =>
            {
                await ResilientSessionContainer.EstablishSessionAsync();
                return(await ResilientSessionContainer.ResilientSession.FindRoleNamesByUserIdAsync(user.Id));
            },
                async (ex) => ResilientSessionContainer.HandleCassandraException <IEnumerable <string> >(ex));

            return(resultList.ToList());
        }
示例#6
0
        public async Task <IPage <ClaimHandle> > PageClaimsAsync(Guid userId, int pageSize, byte[] pagingState)
        {
            var resultList = await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
                async() =>
            {
                await ResilientSessionContainer.EstablishSessionAsync();
                return(await ResilientSessionContainer.ResilientSession.PageClaimsAsync(userId, pageSize, pagingState));
            },
                async (ex) => ResilientSessionContainer.HandleCassandraException <IPage <ClaimHandle> >(ex));

            return(resultList);
        }
        public async Task <CassandraUser> FindByEmailAsync(string email)
        {
            var resultList = await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
                async() =>
            {
                await ResilientSessionContainer.EstablishSessionAsync();
                return(await ResilientSessionContainer.ResilientSession.FindUserByEmailAsync(email));
            },
                async (ex) => ResilientSessionContainer.HandleCassandraException <IEnumerable <CassandraUser> >(ex));

            return(resultList.FirstOrDefault());
        }
示例#8
0
 public async Task AddClaimAsync(CassandraUser user, Claim claim)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         await ResilientSessionContainer.EstablishSessionAsync();
         var claimHandle = new ClaimHandle()
         {
             Type   = claim.Type,
             Value  = claim.Value,
             UserId = user.Id
         };
         await ResilientSessionContainer.ResilientSession.CreateClaimAsync(claimHandle);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
示例#9
0
        public async Task <IList <Claim> > GetClaimsAsync(CassandraUser user)
        {
            var resultList = await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
                async() =>
            {
                await ResilientSessionContainer.EstablishSessionAsync();
                return(await ResilientSessionContainer.ResilientSession.FindClaimHandleByUserIdAsync(user.Id));
            },
                async (ex) => ResilientSessionContainer.HandleCassandraException <IEnumerable <ClaimHandle> >(ex));

            var query = from item in resultList
                        let c = new Claim(item.Type, item.Value)
                                select c;

            return(query.ToList());
        }
示例#10
0
        public async Task <IList <UserLoginInfo> > GetLoginsAsync(CassandraUser user)
        {
            var resultList = await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
                async() =>
            {
                await ResilientSessionContainer.EstablishSessionAsync();
                return(await ResilientSessionContainer.ResilientSession.FindLoginsByUserIdAsync(user.Id));
            },
                async (ex) => ResilientSessionContainer.HandleCassandraException <IEnumerable <ProviderLoginHandle> >(ex));

            var query = from item in resultList
                        let c = new UserLoginInfo(item.LoginProvider, item.ProviderKey)
                                select c;

            return(query.ToList());
        }
示例#11
0
 public async Task RemoveLoginAsync(CassandraUser user, UserLoginInfo login)
 {
     await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
         async() =>
     {
         ProviderLoginHandle providerLogin = new ProviderLoginHandle()
         {
             LoginProvider = login.LoginProvider,
             ProviderKey   = login.ProviderKey,
             TenantId      = ResilientSessionContainer.ResilientSession.TenantId,
             UserId        = user.Id
         };
         await ResilientSessionContainer.EstablishSessionAsync();
         await ResilientSessionContainer.ResilientSession.DeleteLoginsAsync(providerLogin);
     },
         async (ex) => ResilientSessionContainer.HandleCassandraException <Task>(ex));
 }
示例#12
0
        public async Task <CassandraUser> FindAsync(UserLoginInfo login)
        {
            var resultList = await TryWithAwaitInCatch.ExecuteAndHandleErrorAsync(
                async() =>
            {
                await ResilientSessionContainer.EstablishSessionAsync();
                return(await ResilientSessionContainer.ResilientSession.FindLoginByProviderAsync(login.LoginProvider, login.ProviderKey));
            },
                async (ex) => ResilientSessionContainer.HandleCassandraException <IEnumerable <ProviderLoginHandle> >(ex));

            var plhList = resultList.ToList();

            if (!plhList.Any())
            {
                return(null);
            }

            var result = await FindByIdAsync(plhList.First().UserId);

            return(result);
        }