コード例 #1
0
 public TenantUserCreateByEmailHandler(IdentityProviderContext context, IIdentityService identityService,
                                       IEventPublisher publisher)
 {
     this.context         = context;
     this.identityService = identityService;
     this.publisher       = publisher;
 }
コード例 #2
0
 public TenantUserDeleteHandler(IdentityProviderContext context, IEventPublisher publisher,
                                IMapper mapper)
 {
     this.context   = context;
     this.publisher = publisher;
     this.mapper    = mapper;
 }
コード例 #3
0
        public async Task <CreateUserResponse> CreateUser(string userIdentifier, string password, string location, string createdBy)
        {
            var reply = new CreateUserResponse()
            {
                IsSuccessful = false,
                Result       = CreateUserResult.CREATE_OTHER_FAILURE
            };

            using (IdentityProviderContext context = IdentityProviderContext.Create(connectionString))
            {
                try
                {
                    var user = new User(createdBy, userIdentifier, password);
                    context.Users.Add(user);
                    await context.SaveChangesAsync();

                    reply.Result       = CreateUserResult.CREATE_SUCCESS;
                    reply.IsSuccessful = true;
                }
                catch (Exception e)
                {
                    reply.Result       = CreateUserResult.CREATE_DATABASE_FAILURE;
                    reply.IsSuccessful = false;
                }
            }
            return(reply);
        }
コード例 #4
0
 public CreateTenantHandler(IdentityProviderContext context,
                            IMapper mapper,
                            IEventPublisher publisher)
 {
     this.context   = context;
     this.mapper    = mapper;
     this.publisher = publisher;
 }
コード例 #5
0
 public TenantUserEditHandler(IdentityProviderContext context, IIdentityService identityService,
                              IEventPublisher publisher, IMapper mapper)
 {
     this.context         = context;
     this.identityService = identityService;
     this.publisher       = publisher;
     this.mapper          = mapper;
 }
コード例 #6
0
ファイル: UserDeleteHandler.cs プロジェクト: koppa96/eschool
 public UserDeleteHandler(
     IdentityProviderContext context,
     IIdentityService identityService,
     IEventPublisher eventPublisher)
 {
     this.context = context;
     this.identityService = identityService;
     this.eventPublisher = eventPublisher;
 }
コード例 #7
0
 public UserEditHandler(
     IdentityProviderContext context,
     IIdentityService identityService,
     IMapper mapper)
 {
     this.context         = context;
     this.identityService = identityService;
     this.mapper          = mapper;
 }
コード例 #8
0
        public async Task <ICollection <GroupInfo> > GetAllGroups()
        {
            List <GroupInfo> ret = new List <GroupInfo>();

            using (IdentityProviderContext context = IdentityProviderContext.Create(connectionString))
            {
                await Task.Run(() => context.Groups.Where(g => g.ParentGroup == null).ToList().ForEach(delegate(Group g)
                {
                    ret.AddRange(GetGroups(g));
                }));
            }
            return(ret);
        }
コード例 #9
0
        public async Task <ICollection <GroupInfo> > GetUserGroups(string userIdentifier)
        {
            List <GroupInfo> ret = new List <GroupInfo>();

            using (IdentityProviderContext context = IdentityProviderContext.Create(connectionString))
            {
                if (!context.Users.Any(u => u.UserIdentifier == userIdentifier))
                {
                    return(new List <GroupInfo>());
                }

                (context.Users.Include("Groups").Include("Groups.Group").Single(u => u.UserIdentifier == userIdentifier).Groups.ToList().Select(ug => ug.Group).ToList())
                .ForEach(delegate(Group g)
                {
                    Group tmpGrp      = g;
                    GroupInfo tmpGi   = null;
                    GroupInfo childGi = null;
                    while (tmpGrp != null)
                    {
                        if (tmpGi != null)
                        {
                            childGi = tmpGi;
                        }
                        tmpGi = ret.Any(gi => gi.GroupIdentifier == tmpGrp.GroupIdentifier) ?
                                ret.First(gi => gi.GroupIdentifier == tmpGrp.GroupIdentifier) :
                                new GroupInfo {
                            GroupIdentifier = tmpGrp.GroupIdentifier, ParentGroup = null
                        };
                        if (childGi != null)
                        {
                            childGi.ParentGroup = tmpGi;
                        }
                        if (!ret.Any(gi => gi.GroupIdentifier == tmpGi.GroupIdentifier))
                        {
                            ret.Add(tmpGi);
                        }
                        if (tmpGrp.ParentGroupId != null)
                        {
                            tmpGrp = context.Groups.Single(grp => grp.GroupId == tmpGrp.ParentGroupId);
                        }
                        else
                        {
                            tmpGrp = null;
                        }
                    }
                });
            }
            return(ret);
        }
コード例 #10
0
        public async Task <LoginInformation> GetUserLogin(string userIdentifier, string password, string location)
        {
            LoginInformation ret = new LoginInformation()
            {
                IsValid = false, LoginResult = LoginResult.LOGIN_PROVIDER_FAILURE
            };

            try
            {
                using (IdentityProviderContext context = IdentityProviderContext.Create(connectionString))
                {
                    User user = await Task.Run(() => context.Users.FirstOrDefault(u => u.UserIdentifier == userIdentifier));

                    if (user != null)
                    {
                        ret = VerifyLogin(user, password, location);
                        try
                        {
                            LoginAttempt la = new LoginAttempt()
                            {
                                LoginLocation = location, Result = ret.LoginResult, UserId = user.UserId
                            };
                            context.LoginAttempts.Add(la);
                            context.SaveChanges();
                        }
                        catch (Exception e)
                        {
                            ret.IsException          = true;
                            ret.ExceptionInformation = e.ToString();
                            ret.LoginResult          = LoginResult.LOGIN_DATABASE_FAILURE;
                            ret.IsValid = false;
                        }
                    }
                    else
                    {
                        ret.LoginResult = LoginResult.LOGIN_AUTHENTICATION_FAILURE;
                    }
                }
            }
            catch (Exception e)
            {
                ret.IsException          = true;
                ret.ExceptionInformation = e.ToString();
                ret.LoginResult          = LoginResult.LOGIN_OTHER_FAILURE;
            }
            return(ret);
        }
コード例 #11
0
ファイル: TenantListHandler.cs プロジェクト: koppa96/eschool
 public TenantListHandler(IdentityProviderContext context, IConfigurationProvider configurationProvider) : base(context, configurationProvider)
 {
 }
コード例 #12
0
 public TenantDropdownHandler(IdentityProviderContext context)
 {
     this.context = context;
 }
コード例 #13
0
 public TenantUserListHandler(IdentityProviderContext context) : base(context)
 {
 }
コード例 #14
0
 public DeleteTenantHandler(IdentityProviderContext context, IEventPublisher publisher)
 {
     this.context   = context;
     this.publisher = publisher;
 }
コード例 #15
0
 public UserGetHandler(IdentityProviderContext context, IMapper mapper)
 {
     this.context = context;
     this.mapper  = mapper;
 }
コード例 #16
0
 public RegisterModel(UserManager <User> userManager, IdentityProviderContext context)
 {
     this.userManager = userManager;
     this.context     = context;
 }
コード例 #17
0
ファイル: ProfileService.cs プロジェクト: koppa96/eschool
 public ProfileService(UserManager <User> userManager, IdentityProviderContext dbContext)
 {
     this.userManager = userManager;
     this.dbContext   = dbContext;
 }
コード例 #18
0
 public UserSearchHandler(IdentityProviderContext context, IConfigurationProvider configurationProvider)
 {
     this.context = context;
     this.configurationProvider = configurationProvider;
 }
コード例 #19
0
 public TenantUserCreateOrUpdateByIdHandler(IdentityProviderContext context, IEventPublisher publisher)
 {
     this.context   = context;
     this.publisher = publisher;
 }