示例#1
0
        private void User_After(User user, CommonEventArgs eventArgs)
        {
            if (user == null)
            {
                return;
            }

            if (userSearcher == null)
            {
                userSearcher = (UserSearcher)SearcherFactory.GetSearcher(UserSearcher.CODE);
            }

            if (eventArgs.EventOperationType == EventOperationType.Instance().Update() ||
                eventArgs.EventOperationType == EventOperationType.Instance().ActivateUser() ||
                eventArgs.EventOperationType == EventOperationType.Instance().Approved() ||
                eventArgs.EventOperationType == EventOperationType.Instance().BanUser() ||
                eventArgs.EventOperationType == EventOperationType.Instance().UnbanUser() ||
                eventArgs.EventOperationType == EventOperationType.Instance().Disapproved())
            {
                //使用UserSearcher更新索引
                userSearcher.Update(user);
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                //使用UserSearcher删除索引
                userSearcher.Delete(user.UserId);
            }
        }
示例#2
0
        private void UserProfile_After(UserProfile userProfile, CommonEventArgs eventArgs)
        {
            if (userProfile == null)
            {
                return;
            }

            if (userSearcher == null)
            {
                userSearcher = (UserSearcher)SearcherFactory.GetSearcher(UserSearcher.CODE);
            }

            if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                //增加新索引的事件由UserProfile触发,因为没有用户基本资料,就没有索引和搜索的价值
                User user = userService.GetFullUser(userProfile.UserId);
                userSearcher.Insert(user);
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Update())
            {
                //使用UserSearcher更新索引
                User user = userService.GetFullUser(userProfile.UserId);
                userSearcher.Update(user);
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                //使用UserSearcher删除索引(Profile删除,User不一定删除)
                User user = userService.GetFullUser(userProfile.UserId);
                userSearcher.Update(user);//因为是删除用户资料,不是删除用户本身,所以此处是update
            }
        }
示例#3
0
		public override void SetUp()
		{
			base.SetUp();

			var accessRestrictor = serviceProvider.GetService<IAccessRestrictor>();
			userSearcher = new UserSearcher(db, accessRestrictor, serviceProvider.GetServices<ISearcher>(), serviceProvider.GetServices<IFilter>());
		}
示例#4
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="context"></param>
 /// <param name="application"></param>
 /// <param name="userManager"></param>
 /// <param name="signInManager"></param>
 /// <param name="userSearcher"></param>
 public PasswordChanger(ICrocoAmbientContextAccessor context, ICrocoApplication application,
                        UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager,
                        UserSearcher userSearcher) : base(context, application)
 {
     UserManager   = userManager;
     SignInManager = signInManager;
     UserSearcher  = userSearcher;
 }
示例#5
0
 /// <summary>
 /// 删除用户
 /// </summary>
 /// <param name="user"></param>
 /// <param name="eventArgs"></param>
 private void DeleteUser_After(User user, DeleteUserEventArgs eventArgs)
 {
     if (userSearcher == null)
     {
         userSearcher = (UserSearcher)SearcherFactory.GetSearcher(UserSearcher.CODE);
     }
     //使用UserSearcher删除索引
     userSearcher.Delete(user.UserId);
 }
 public WelcomeWindowViewModel(
     Authenticator authenticatorServ,
     FriendsService friendsServ,
     UserSearcher userSerchingServ,
     Services.UserValidationService valServ)
 {
     authenticatorService  = authenticatorServ;
     friendsService        = friendsServ;
     userValidationService = valServ;
     userSerchingService   = userSerchingServ;
 }
 /// <summary>
 /// 为用户添加标签时触发
 /// </summary>
 private void AddTagsToUser_BatchAfter(IEnumerable<string> senders, TagEventArgs eventArgs)
 {
     if (eventArgs.TenantTypeId == TenantTypeIds.Instance().User())
     {
         long userId = eventArgs.ItemId;
         if (userSearcher == null)
         {
             userSearcher = (UserSearcher)SearcherFactory.GetSearcher(UserSearcher.CODE);
         }
         userSearcher.Update(userService.GetFullUser(userId));
     }
 }
 private void AddTag(string tagName, TagEventArgs eventArgs)
 {
     if (eventArgs.TenantTypeId == TenantTypeIds.Instance().User())
     {
         long userId = eventArgs.ItemId;
         if (userSearcher == null)
         {
             userSearcher = (UserSearcher)SearcherFactory.GetSearcher(UserSearcher.CODE);
         }
         userSearcher.Update(userService.GetFullUser(userId));
     }
 }
示例#9
0
 private void DeleteItemInTags(ItemInTag sender, CommonEventArgs eventArgs)
 {
     if (sender.TenantTypeId == TenantTypeIds.Instance().User())
     {
         long userId = sender.ItemId;
         if (userSearcher == null)
         {
             userSearcher = (UserSearcher)SearcherFactory.GetSearcher(UserSearcher.CODE);
         }
         userSearcher.Update(userService.GetFullUser(userId));
     }
 }
示例#10
0
 /// <summary>
 /// 为用户添加标签时触发
 /// </summary>
 private void AddTagsToUser_BatchAfter(IEnumerable <string> senders, TagEventArgs eventArgs)
 {
     if (eventArgs.TenantTypeId == TenantTypeIds.Instance().User())
     {
         long userId = eventArgs.ItemId;
         if (userSearcher == null)
         {
             userSearcher = (UserSearcher)SearcherFactory.GetSearcher(UserSearcher.CODE);
         }
         userSearcher.Update(userService.GetFullUser(userId));
     }
 }
示例#11
0
 private void AddTag(string tagName, TagEventArgs eventArgs)
 {
     if (eventArgs.TenantTypeId == TenantTypeIds.Instance().User())
     {
         long userId = eventArgs.ItemId;
         if (userSearcher == null)
         {
             userSearcher = (UserSearcher)SearcherFactory.GetSearcher(UserSearcher.CODE);
         }
         userSearcher.Update(userService.GetFullUser(userId));
     }
 }
示例#12
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="ambientContext"></param>
 /// <param name="application"></param>
 /// <param name="signInManager"></param>
 /// <param name="userSearcher"></param>
 /// <param name="passwordHashValidator"></param>
 /// <param name="authenticationManager"></param>
 /// <param name="logger"></param>
 public AccountLoginService(ICrocoAmbientContextAccessor ambientContext,
                            ICrocoApplication application,
                            SignInManager <ApplicationUser> signInManager,
                            UserSearcher userSearcher,
                            PasswordHashValidator passwordHashValidator,
                            IApplicationAuthenticationManager authenticationManager,
                            ILogger <AccountLoginService> logger) : base(ambientContext, application, logger)
 {
     SignInManager         = signInManager;
     UserSearcher          = userSearcher;
     PasswordHashValidator = passwordHashValidator;
     AuthenticationManager = authenticationManager;
 }
示例#13
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="ambientContext"></param>
 /// <param name="application"></param>
 /// <param name="userManager"></param>
 /// <param name="signInManager"></param>
 /// <param name="userSearcher"></param>
 /// <param name="passwordValidator"></param>
 /// <param name="logger"></param>
 public AccountRegistrationService(ICrocoAmbientContextAccessor ambientContext,
                                   ICrocoApplication application,
                                   UserManager <ApplicationUser> userManager,
                                   SignInManager <ApplicationUser> signInManager,
                                   UserSearcher userSearcher,
                                   CltPasswordValidator passwordValidator,
                                   ILogger <AccountRegistrationService> logger) : base(ambientContext, application, logger)
 {
     UserManager       = userManager;
     SignInManager     = signInManager;
     UserSearcher      = userSearcher;
     PasswordValidator = passwordValidator;
 }
示例#14
0
 /// <summary>
 /// 删除和更新标签时触发
 /// </summary>
 private void DeleteUpdateTags_Before(Tag sender, CommonEventArgs eventArgs)
 {
     if (sender.TenantTypeId == TenantTypeIds.Instance().User())
     {
         if (eventArgs.EventOperationType == EventOperationType.Instance().Delete() || eventArgs.EventOperationType == EventOperationType.Instance().Update())
         {
             //根据标签获取所有使用该标签的(内容项)用户
             IEnumerable <long> userIds = tagService.GetItemIds(sender.TagName, null);
             if (userSearcher == null)
             {
                 userSearcher = (UserSearcher)SearcherFactory.GetSearcher(UserSearcher.CODE);
             }
             userSearcher.Update(userService.GetFullUsers(userIds));
         }
     }
 }
示例#15
0
        private void FirstUploadAvatar_After(User user, CropAvatarEventArgs eventArgs)
        {
            if (user == null)
            {
                return;
            }

            if (userSearcher == null)
            {
                userSearcher = (UserSearcher)SearcherFactory.GetSearcher(UserSearcher.CODE);
            }

            if (eventArgs.IsFirst)
            {
                //使用UserSearcher更新索引
                userSearcher.Update(user);
            }
        }
示例#16
0
        /// <summary>
        /// Авторизоваться по номеру телефона
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <LoginResultModel> LoginByPhoneNumberAsync(LoginByPhoneNumberModel model)
        {
            var validation = ValidateModel(model);

            if (!validation.IsSucceeded)
            {
                return(new LoginResultModel(LoginErrorType.ModelNotValid, validation.Message));
            }

            var user = await UserSearcher.GetUserByPhoneNumberAsync(model.PhoneNumber);

            if (user == null)
            {
                return(UnSuccessfulLoginAttempt());
            }

            return(await LoginAsync(GetLoginModel(model, user.Email)));
        }
示例#17
0
        public async Task <BaseApiResponse <LoginResultModel> > LoginByPhoneNumberAsync(LoginByPhoneNumberModel model, SignInManager <ApplicationUser> signInManager)
        {
            var validation = ValidateModel(model);

            if (!validation.IsSucceeded)
            {
                return(new BaseApiResponse <LoginResultModel>(validation));
            }

            var searcher = new UserSearcher(AmbientContext);

            var user = await searcher.GetUserByPhoneNumberAsync(model.PhoneNumber);

            if (user == null)
            {
                return(new BaseApiResponse <LoginResultModel>(false, "Пользователь не найден по указанному номеру телефона"));
            }

            return(await LoginAsync(new LoginModel(model, user.Email), signInManager));
        }
示例#18
0
        public async Task <BaseApiResponse> UserForgotPasswordByPhoneHandlerAsync(ForgotPasswordModelByPhone model, UserManager <ApplicationUser> userManager)
        {
            var validation = ValidateModel(model);

            if (!validation.IsSucceeded)
            {
                return(validation);
            }

            if (IsAuthenticated)
            {
                return(new BaseApiResponse(false, "Вы авторизованы в системе"));
            }

            var searcher = new UserSearcher(AmbientContext);

            var user = await searcher.GetUserByPhoneNumberAsync(model.PhoneNumber);

            return(await UserForgotPasswordNotificateHandlerAsync(user.ToEntity(), userManager));
        }
示例#19
0
        public UserProfileViewModel(
            MessageHistoryService messageHistoryServ,
            UserSearcher userSearchingServ,
            FriendsService friendServ,
            Messanger mesServ,
            SessionInfo session,
            MessageSearcher mesSerServ,
            Services.PhotoService.UsersPhotoService profilePhotoService,
            ImageService imageServ,
            Authenticator authenticatorServ,
            ImageUrlService imageUrlServ)
        {
            Messages                 = new FlowDocument();
            controlsVisibility       = false;
            canExecute               = true;
            CurrentSession           = session;
            messageHistoryService    = messageHistoryServ;
            userSearchingService     = userSearchingServ;
            friendService            = friendServ;
            this.profilePhotoService = profilePhotoService;
            imageService             = imageServ;
            Friends = friendService.GetFriends(currentSession.LoggedUser.Id).ResultTask.Result;
            authenticatorService = authenticatorServ;
            imageUrlService      = imageUrlServ;

            FindFriendEmailOrLogin = string.Empty;
            messengerService       = mesServ;
            DocWidth = 248;
            FontSize = 13;
            messageSearchingService = mesSerServ;
            var imageUrl = profilePhotoService.GetProfilePhoto(currentSession.LoggedUser.ProfilePhotoId).Url;

            if (imageUrl.Contains(@"\Resources\images\ProfilePhotos"))
            {
                ImageSource = imageUrl;
            }
            else
            {
                ImageSource = imageUrlService.GetImageUrl(currentSession.LoggedUser.ProfilePhotoId);
            }
        }
示例#20
0
        public async Task <BaseApiResponse> UserForgotPasswordByEmailHandlerAsync(ForgotPasswordModel model, UserManager <ApplicationUser> userManager)
        {
            if (model == null)
            {
                return(new BaseApiResponse(false, "Вы подали пустую модель"));
            }

            if (IsAuthenticated)
            {
                return(new BaseApiResponse(false, "Вы авторизованы в системе"));
            }

            var searcher = new UserSearcher(AmbientContext);

            var user = await searcher.GetUserByEmailAsync(model.Email);

            if (user == null)
            {
                return(new BaseApiResponse(false, $"Пользователь не найден по указанному электронному адресу {model.Email}"));
            }

            return(await UserForgotPasswordNotificateHandlerAsync(user.ToEntity(), userManager));
        }
示例#21
0
        private async Task <RegistrationResultInner> RegisterHelpMethodAsync(RegisterModel model, string[] roleNames = null)
        {
            var passwordValidation = PasswordValidator.Validate(model.Password);

            if (!passwordValidation.IsOk)
            {
                return(new RegistrationResultInner(RegistrationErrorResultType.UnAcceptablePassword, passwordValidation.ErrorMessage));
            }

            var accountSettings = GetSetting <AccountSettingsModel>();

            var user = new ApplicationUser
            {
                UserName       = model.Email,
                Email          = model.Email,
                PhoneNumber    = model.PhoneNumber,
                EmailConfirmed = !accountSettings.ShouldUsersConfirmEmail
            };

            var checkResult = await CheckUserAsync(user);

            if (!checkResult.Succeeded)
            {
                return(checkResult);
            }

            var creationResult = await UserManager.CreateAsync(user, model.Password);

            if (!creationResult.Succeeded)
            {
                var firstError = creationResult.Errors.ToList().First().Description;

                return(new RegistrationResultInner(RegistrationErrorResultType.UserManagerError, firstError));
            }

            if (roleNames != null && roleNames.Length > 0)
            {
                await UserManager.AddToRolesAsync(user, roleNames);
            }

            //Создается внутренний пользователь
            CreateHandled(new Client
            {
                Id          = user.Id,
                Email       = model.Email,
                Name        = model.Name,
                Surname     = model.Surname,
                Patronymic  = model.Patronymic,
                PhoneNumber = model.PhoneNumber
            });

            var result = await TrySaveChangesAndReturnResultAsync("Пользователь создан");

            if (!result.IsSucceeded)
            {
                await RemoveUserAndClient(user.Id);

                return(new RegistrationResultInner(RegistrationErrorResultType.ClientAddingError, result.Message));
            }

            var userModel = await UserSearcher.GetUserByIdAsync(user.Id);

            return(new RegistrationResultInner(userModel));
        }
 public FindHandler()
 {
     userSearchService = NinjectKernel.Get <UserSearcher>();
 }
示例#23
0
        private void User_After(User user, CommonEventArgs eventArgs)
        {
            if (user == null)
            {
                return;
            }

            if (userSearcher == null)
            {
                userSearcher = (UserSearcher)SearcherFactory.GetSearcher(UserSearcher.CODE);
            }

            if (eventArgs.EventOperationType == EventOperationType.Instance().Update()
                || eventArgs.EventOperationType == EventOperationType.Instance().ActivateUser()
                || eventArgs.EventOperationType == EventOperationType.Instance().Approved()
                || eventArgs.EventOperationType == EventOperationType.Instance().BanUser()
                || eventArgs.EventOperationType == EventOperationType.Instance().UnbanUser()
                || eventArgs.EventOperationType == EventOperationType.Instance().Disapproved())
            {
                //使用UserSearcher更新索引
                userSearcher.Update(user);
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                //使用UserSearcher删除索引
                userSearcher.Delete(user.UserId);
            }
        }
示例#24
0
 private void Awake()
 {
     userSearcher    = LogicManager.GetLogicComponent <UserSearcher>();
     userMenuElement = userUI.GetComponent <TweenableMenuElement>();
 }
示例#25
0
        private void FirstUploadAvatar_After(User user, CropAvatarEventArgs eventArgs)
        {
            if (user == null)
            {
                return;
            }

            if (userSearcher == null)
            {
                userSearcher = (UserSearcher)SearcherFactory.GetSearcher(UserSearcher.CODE);
            }

            if (eventArgs.IsFirst)
            {
                //使用UserSearcher更新索引
                userSearcher.Update(user);
            }
        }
示例#26
0
        private void UserProfile_After(UserProfile userProfile, CommonEventArgs eventArgs)
        {
            if (userProfile == null)
            {
                return;
            }

            if (userSearcher == null)
            {
                userSearcher = (UserSearcher)SearcherFactory.GetSearcher(UserSearcher.CODE);
            }

            if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                //增加新索引的事件由UserProfile触发,因为没有用户基本资料,就没有索引和搜索的价值
                User user = userService.GetFullUser(userProfile.UserId);
                userSearcher.Insert(user);
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Update())
            {
                //使用UserSearcher更新索引
                User user = userService.GetFullUser(userProfile.UserId);
                userSearcher.Update(user);
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                //使用UserSearcher删除索引(Profile删除,User不一定删除)
                User user = userService.GetFullUser(userProfile.UserId);
                userSearcher.Update(user);//因为是删除用户资料,不是删除用户本身,所以此处是update
            }
        }
示例#27
0
 /// <summary>
 /// 删除用户
 /// </summary>
 /// <param name="user"></param>
 /// <param name="eventArgs"></param>
 private void DeleteUser_After(User user, DeleteUserEventArgs eventArgs)
 {
     if (userSearcher == null)
     {
         userSearcher = (UserSearcher)SearcherFactory.GetSearcher(UserSearcher.CODE);
     }
         //使用UserSearcher删除索引
         userSearcher.Delete(user.UserId);
 }
示例#28
0
 private void DeleteItemInTags(ItemInTag sender, CommonEventArgs eventArgs)
 {
     if (sender.TenantTypeId == TenantTypeIds.Instance().User())
     {
         long userId = sender.ItemId;
         if (userSearcher == null)
         {
             userSearcher = (UserSearcher)SearcherFactory.GetSearcher(UserSearcher.CODE);
         }
         userSearcher.Update(userService.GetFullUser(userId));
     }
 }
        public IUser Find_User(String user_id)
        {
            IUser user = null;
                user = new UserSearcher(context).Get_By_ID(user_id);

            return user;
        }
 public IUser[] Find_All_Users()
 {
     //ObjectSet<User> os = new UserSearcher(context).FindAll();
     IUser[] users = new UserSearcher(context).FindAll().ToArray();
     return users;
 }
示例#31
0
 public RootHealthCheck(ISettingsFactory settingsFactory, UserSearcher userSearcher)
 {
     SettingsFactory = settingsFactory;
     UserSearcher    = userSearcher;
 }
示例#32
0
 /// <summary>
 /// 删除和更新标签时触发
 /// </summary>
 private void DeleteUpdateTags_Before(Tag sender, CommonEventArgs eventArgs)
 {
     if (sender.TenantTypeId == TenantTypeIds.Instance().User())
     {
         if (eventArgs.EventOperationType == EventOperationType.Instance().Delete() || eventArgs.EventOperationType == EventOperationType.Instance().Update())
         {
             //根据标签获取所有使用该标签的(内容项)用户
             IEnumerable<long> userIds = tagService.GetItemIds(sender.TagName, null);
             if (userSearcher == null)
             {
                 userSearcher = (UserSearcher)SearcherFactory.GetSearcher(UserSearcher.CODE);
             }
             userSearcher.Update(userService.GetFullUsers(userIds));
         }
     }
 }