public void CallsSaveChangesOnRepository()
 {
     var repo = new Mock<IUserAccountRepository>();
     var sub = new UserAccountService(repo.Object, null, null);
     sub.SaveChanges();
     repo.Verify(x => x.SaveChanges());
 }
 public OwinAuthenticationService(
     UserAccountService svc,
     IDictionary<string, object> environment
 )
     : this(svc, environment, null)
 {
 }
 public LoginController(
     UserAccountService userService, 
     AuthenticationService authSvc)
 {
     this.userAccountService = userService;
     this.authSvc = authSvc;
 }
 public OwinAuthenticationService(
     UserAccountService svc,
     IDictionary<string, object> env
 )
     : this(MembershipRebootOwinConstants.AuthenticationType, svc, env, null)
 {
 }
 public void CallsDisposeOnUserRepo()
 {
     var userAccountRepo = new Mock<IUserAccountRepository>();
     var sub = new UserAccountService(userAccountRepo.Object, null, null);
     sub.Dispose();
     userAccountRepo.Verify(x => x.Dispose());
 }
 public void CallsUpdateOnRepository()
 {
     var repo = new Mock<IUserAccountRepository>();
     var sub = new UserAccountService(repo.Object, null, null);
     var ua = new UserAccount();
     sub.Update(ua);
     repo.Verify(x => x.Update(ua));
 }
 public void Init()
 {
     securitySettings = new SecuritySettings();
     securitySettings.PasswordHashingIterationCount = 1; // tests will run faster
     configuration = new MembershipRebootConfiguration(securitySettings);
     repository = new FakeUserAccountRepository(); 
     subject = new UserAccountService(configuration, repository);
 }
 public OwinAuthenticationService(
     string authenticationType,
     UserAccountService svc,
     IDictionary<string, object> env
 )
     : this(authenticationType, svc, env, null)
 {
 }
        public void ProcessAvatarPickerRequest(IClientAPI client, UUID avatarID, UUID RequestID, string query)
        {
            //EventManager.TriggerAvatarPickerRequest();

            List <UserAccount> accounts = UserAccountService.GetUserAccounts(RegionInfo.ScopeID, query);

            if (accounts == null)
            {
                return;
            }

            AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply);

            // TODO: don't create new blocks if recycling an old packet

            AvatarPickerReplyPacket.DataBlock[] searchData =
                new AvatarPickerReplyPacket.DataBlock[accounts.Count];
            AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock();

            agentData.AgentID     = avatarID;
            agentData.QueryID     = RequestID;
            replyPacket.AgentData = agentData;
            //byte[] bytes = new byte[AvatarResponses.Count*32];

            int i = 0;

            foreach (UserAccount item in accounts)
            {
                UUID translatedIDtem = item.PrincipalID;
                searchData[i]           = new AvatarPickerReplyPacket.DataBlock();
                searchData[i].AvatarID  = translatedIDtem;
                searchData[i].FirstName = Utils.StringToBytes((string)item.FirstName);
                searchData[i].LastName  = Utils.StringToBytes((string)item.LastName);
                i++;
            }
            if (accounts.Count == 0)
            {
                searchData = new AvatarPickerReplyPacket.DataBlock[0];
            }
            replyPacket.Data = searchData;

            AvatarPickerReplyAgentDataArgs agent_data = new AvatarPickerReplyAgentDataArgs();

            agent_data.AgentID = replyPacket.AgentData.AgentID;
            agent_data.QueryID = replyPacket.AgentData.QueryID;

            List <AvatarPickerReplyDataArgs> data_args = new List <AvatarPickerReplyDataArgs>();

            for (i = 0; i < replyPacket.Data.Length; i++)
            {
                AvatarPickerReplyDataArgs data_arg = new AvatarPickerReplyDataArgs();
                data_arg.AvatarID  = replyPacket.Data[i].AvatarID;
                data_arg.FirstName = replyPacket.Data[i].FirstName;
                data_arg.LastName  = replyPacket.Data[i].LastName;
                data_args.Add(data_arg);
            }
            client.SendAvatarPickerReply(agent_data, data_args);
        }
예제 #10
0
        public MembershipRebootUserService(DefaultUserAccountServiceContainer container)
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            this.userAccountService = container.Service;
        }
 public ValidationResult Validate(UserAccountService service, UserAccount account, string value)
 {
     if (value.Length < 4)
     {
         return new ValidationResult("Password must be at least 4 characters long");
     }
     
     return null;
 }
예제 #12
0
 public AccountController(
     UserAccountService userAccountService,
     IStringLocalizer localizer,
     IIdentityServerInteractionService interaction)
 {
     this._userAccountService = userAccountService;
     this._localizer          = localizer;
     this._interaction        = interaction;
 }
예제 #13
0
        public ValidationResult Validate(UserAccountService service, UserAccount account, string value)
        {
            if (value.Length < 4)
            {
                return(new ValidationResult("Password must be at least 4 characters long"));
            }

            return(null);
        }
예제 #14
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         this.userAccountService.TryDispose();
         this.userAccountService = null;
     }
     base.Dispose(disposing);
 }
 public OwinAuthenticationService(
     UserAccountService svc,
     IDictionary<string, object> environment,
     ClaimsAuthenticationManager transformer
 )
     : base(svc, transformer)
 {
     context = new OwinContext(environment);
 }
예제 #16
0
        public ActionResult Login(UserAccountModel model, string btnLogin)
        {
            if (ModelState.IsValid)
            {
                using (UserAccountService service = new UserAccountService())
                {
                    UserAccountModel userInfo = new UserAccountModel();

                    var    Info           = service.getInfoUser(model);
                    string IpAddress      = GetIpAddress();
                    string UserAgent      = Request.UserAgent;
                    string BrowserType    = Request.Browser.Type;
                    string BrowserVersion = Request.Browser.Version;

                    if (Info != null)
                    {
                        userInfo = Info;
                        if (userInfo.LOGIN_LOCK_FLG != "0")
                        {
                            //UserAccountModel model = new UserAccountModel();
                            ViewBag.ErrorLogin = "******";
                            ModelState.AddModelError("", "Tài khoản đang bị khóa!");
                            return(View(userInfo));
                        }
                        if (userInfo.LOGIN_LOCK_FLG == "0")
                        {
                            if (userInfo.PASSWORD_LAST_UPDATE_DATE.Year < 2017 || Utility.GetCurrentDateTime() >
                                userInfo.PASSWORD_LAST_UPDATE_DATE.AddMonths(6))
                            {
                                ViewBag.PASSWORD_EXPIRED = string.Format(Message.PasswordOnExpired);
                                return(this.RedirectToAction("ChangePassword", "ChangePassword"));
                            }
                            userInfo.IpAddress      = IpAddress;
                            userInfo.UserAgent      = UserAgent;
                            userInfo.BrowserType    = BrowserType;
                            userInfo.BrowserVersion = BrowserVersion;
                            // Update session chua can thiet
                            //UpdateCmnEntityModel(userInfo);
                            //Session["USER_INFO"] = userInfo;

                            ViewBag.ErrorLogin = "";
                            return(this.RedirectToAction("Index", "Home"));
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", "Thông tin đăng nhập không chính xác!");
                        return(View(userInfo));
                    }
                }
            }
            {
                var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray();
            }

            return(View());
        }
예제 #17
0
 public void Arrange()
 {
     _userId = Guid.NewGuid().ToString();
     UserAccountService.FindByEmail("*****@*****.**").Returns(new LoginUser()
     {
         Id = _userId
     });
     _createInvitationRequest = BuildCreateInvitationRequest();
 }
예제 #18
0
 public AccountController(
     AuthenticationService <NhUserAccount> authenticationService,
     ISession session,
     UserAccountService <NhUserAccount> userAccountService)
 {
     this.authenticationService = authenticationService;
     this.session            = session;
     this.userAccountService = userAccountService;
 }
        public AngualrUserService(UserAccountService userAccountService)
        {
            if (userAccountService == null)
            {
                throw new ArgumentNullException("userAccountService");
            }

            this.userAccountService = userAccountService;
        }
        public async Task Unmute([NoSelf] IGuildUser user)
        {
            await SendLogToChannel($"{UserAccountService.GetUsername(Context.User)} has unmuted user {user.Mention}");

            _logger.Log($"{UserAccountService.GetUsername(Context.User)} has unmuted user {user.Username + user.Id}");
            await Context.Channel.SendMessageAsync($"*Vincenzo zerwał knebel z buzi {user.Mention}*\nEhh... Szkoda, dopiero się rozkręcałem!");

            try { await user.RemoveRoleAsync(await GetMuteRole(user.Guild)).ConfigureAwait(false); } catch { }
        }
예제 #21
0
        public async Task setUserOnline_SetOnline_UserSetOnline(int userId)
        {
            IDataGateway              dataGateway              = new SQLServerGateway();
            IConnectionStringData     connectionString         = new ConnectionStringData();
            IPublicUserProfileRepo    publicUserProfileRepo    = new PublicUserProfileRepo(dataGateway, connectionString);
            IUserAccountRepository    userAccountRepository    = new UserAccountRepository(dataGateway, connectionString);
            IUserProfileRepository    userProfileRepository    = new UserProfileRepository(dataGateway, connectionString);
            IUserProfileService       userProfileService       = new UserProfileService(userProfileRepository);
            IUserAccountService       userAccountService       = new UserAccountService(userAccountRepository);
            IValidationService        validationService        = new ValidationService(userAccountService, userProfileService);
            IPublicUserProfileService publicUserProfileService = new PublicUserProfileService(publicUserProfileRepo, validationService);



            PublicUserProfileManager publicUserProfileManager = new PublicUserProfileManager(publicUserProfileService);

            PublicUserProfileModel model = new PublicUserProfileModel();

            model.UserId = userId;


            try
            {
                await publicUserProfileManager.CeatePublicUserProfileAsync(model);


                await publicUserProfileManager.SetUserOnlineAsync(userId);



                IEnumerable <PublicUserProfileModel> models = await publicUserProfileRepo.GetAllPublicProfiles();

                if (models == null)
                {
                    Assert.IsTrue(false);
                }
                if (models.Count() == 0)
                {
                    Assert.IsTrue(false);
                }
                foreach (var profile in models)
                {
                    if (profile.Status == "Online")
                    {
                        Assert.IsTrue(true);
                    }
                    else
                    {
                        Assert.IsTrue(false);
                    }
                }
            }
            catch
            {
                Assert.IsTrue(false);
            }
        }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         this.userAccountService.TryDispose();
         this.userAccountService = null;
     }
     base.Dispose(disposing);
 }
 public InvitationsPutController(
     UserAccountService userAccountService,
     IEmailService emailService,
     IClientStore clientStore)
 {
     this.userAccountService = userAccountService;
     this.emailService       = emailService;
     this.clientStore        = clientStore;
 }
        public ValidationResult Validate(UserAccountService <CustomUserAccount> service, CustomUserAccount account, string value)
        {
            if (value.Contains("R"))
            {
                return(new ValidationResult("You can't use an 'R' in your password (for some reason)"));
            }

            return(null);
        }
 public MembershipRebootIdentityManagerService(
     UserAccountService <TAccount> userAccountService,
     IUserAccountQuery <TAccount> userQuery,
     GroupService <TGroup> groupService,
     IGroupQuery groupQuery,
     UserManagementMetadata metadata)
     : this(userAccountService, userQuery, groupService, groupQuery, () => Task.FromResult(metadata))
 {
 }
예제 #26
0
 public ChangeEmailPostController(
     UserAccountService userAccountService,
     IEmailService emailService,
     IClientStore clientStore)
 {
     this._userAccountService = userAccountService;
     this._emailService = emailService;
     this._clientStore = clientStore;
 }
        public static IUserService Factory(string connString)
        {
            var db   = new DefaultMembershipRebootDatabase(connString);
            var repo = new DefaultUserAccountRepository(db);
            var userAccountService = new UserAccountService(config, repo);
            var userSvc            = new MembershipRebootUserService <UserAccount>(userAccountService, db);

            return(userSvc);
        }
예제 #28
0
        public MembershipRebootUserService(UserAccountService <TAccount> userAccountService)
        {
            if (userAccountService == null)
            {
                throw new ArgumentNullException("userAccountService");
            }

            this.userAccountService = userAccountService;
        }
 public OwinAuthenticationService(
     UserAccountService svc,
     IDictionary <string, object> environment,
     ClaimsAuthenticationManager transformer
     )
     : base(svc, transformer)
 {
     context = new OwinContext(environment);
 }
예제 #30
0
        static void allUserTest()
        {
            IUserAccountService   userAccountService = new UserAccountService(_connectionString);
            List <MembershipUser> allUsers           = userAccountService.GetAllUsers();

            foreach (MembershipUser user in allUsers)
            {
                logger.Info(user.Username);
            }
        }
예제 #31
0
        public void Init()
        {
            oldIterations = SecuritySettings.Instance.PasswordHashingIterationCount;
            SecuritySettings.Instance.PasswordHashingIterationCount = 1; // tests will run faster

            securitySettings = new SecuritySettings();
            configuration    = new MembershipRebootConfiguration(securitySettings);
            repository       = new FakeUserAccountRepository();
            subject          = new UserAccountService(configuration, repository);
        }
예제 #32
0
 public UserAccountController(ILogger <UserAccountController> logger)
 {
     _logger    = logger;
     api        = new APIHelper();
     uas        = new UserAccountService();
     attributes = new HashSet <string>()
     {
         "AccountUsername", "EmailAddress", "Password"
     };
 }
        public void SearchUserByBannerID_Returns_Null_If_Not_Found()
        {
            BannerID testBannerID = BannerID.CreateBannerID("A00000000");
            var      mockRepo     = new Mock <IActiveDirectoryRepository>();

            mockRepo.Setup(repo => repo.FindUserByBannerID(testBannerID)).Returns((User)null);
            UserAccountService userAccountService = new UserAccountService(mockRepo.Object);

            Assert.IsNull(userAccountService.SearchUserByBannerID(testBannerID));
        }
예제 #34
0
        public static IUserManager Create()
        {
            var repo = new DefaultUserAccountRepository();

            repo.QueryFilter = RelationalUserAccountQuery.Filter;
            repo.QuerySort   = RelationalUserAccountQuery.Sort;
            var svc = new UserAccountService(config, repo);

            return(new UserManager <UserAccount>(svc, repo, repo));
        }
예제 #35
0
        public IdentityRepository()
        {
            var settings = SecuritySettings.FromConfiguration();

            settings.RequireAccountVerification = false;
            var config = new MembershipRebootConfiguration(settings);

            this.userSvc  = new UserAccountService(config, new BrockAllen.MembershipReboot.Ef.DefaultUserAccountRepository());
            this.groupSvc = new GroupService(new BrockAllen.MembershipReboot.Ef.DefaultGroupRepository());
        }
        public IUserAccountService Build()
        {
            var service = new UserAccountService(_userReadRepository.Object, _registerUserStrategy.Object,
                                                 _activateUserStrategy.Object, _resetForgottenPasswordStrategy.Object, _sendPasswordCodeStrategy.Object,
                                                 _resendActivationCodeStrategy.Object, _resendAccountUnlockCodeStrategy.Object,
                                                 _unlockAccountStrategy.Object, _updateUsernameStrategy.Object, _sendPendingUsernameCodeStrategy.Object,
                                                 _logger.Object);

            return(service);
        }
예제 #37
0
 public ActionResult SubmitFeedback(Feedback f)
 {
     if (ModelState.IsValid)
     {
         UserAccountService uas = new UserAccountService();
         uas.SubmitFeedback(Convert.ToInt32(Session["Id"]), f);
         return(RedirectToAction("Feedbacks"));
     }
     return(View(f));
 }
        public void ChangePassword(ChangePasswordRequest request)
        {
            var userAccountRepository = new UserAccountRepository();

            UserAccountService.ChangePassword(
                request,
                ContextualUserId,
                userAccountRepository.GetById,
                userAccountRepository.SetPassword);
        }
        public UserService(UserAccountService <TAccount> userAccountService, IDisposable cleanup)
        {
            if (userAccountService == null)
            {
                throw new ArgumentNullException("userAccountService");
            }

            this.userAccountService = userAccountService;
            this.cleanup            = cleanup;
        }
예제 #40
0
        public IIdentityManagerService Create()
        {
            var repo = new DefaultUserAccountRepository(this.connString);

            repo.QueryFilter = RelationalUserAccountQuery.Filter;
            repo.QuerySort   = RelationalUserAccountQuery.Sort;
            var svc = new UserAccountService(config, repo);

            return(new IdentityManagerService <UserAccount>(svc, repo, repo));
        }
예제 #41
0
        // Update all updatable fields
        //
        public bool StoreUserAccount(UserAccount data)
        {
            bool ret = UserAccountService.StoreUserAccount(data);

            if (ret)
            {
                m_Cache.Cache(data.PrincipalID, data);
            }
            return(ret);
        }
 public OwinAuthenticationService(
     string authenticationType,
     UserAccountService svc,
     IDictionary<string, object> env,
     ClaimsAuthenticationManager transformer
 )
     : base(svc, transformer)
 {
     this.authenticationType = authenticationType;
     context = new OwinContext(env);
 }
 private void InitDatabase()
 {
     var svc = new UserAccountService(new EFUserAccountRepository(), null, null);
     if (svc.GetByUsername("admin") == null)
     {
         var account = svc.CreateAccount("admin", "admin123", "*****@*****.**");
         svc.VerifyAccount(account.VerificationKey);
         account.AddClaim(ClaimTypes.Role, "Administrator");
         svc.Update(account);
     }
 }
예제 #44
0
 protected void btRegister_Click(object sender, EventArgs e)
 {
     UserAccountService uas = new UserAccountService();
     if (uas.UserExists(txtUserName.Text) || txtPassword.Text != txtConfirm.Text)
         lblResult.Text = "UserName already exists or Password Mistach";
     else
     {
         uas.CreateAccount(txtUserName.Text, txtPassword.Text);
         Response.Redirect("Login.aspx");
     }
 }
 private void InitDatabase()
 {
     var svc = new UserAccountService(new DefaultUserAccountRepository(SecuritySettings.Instance.ConnectionStringName), null, null);
     if (svc.GetByUsername("admin") == null)
     {
         var account = svc.CreateAccount("admin", "admin123", "*****@*****.**");
         svc.VerifyAccount(account.VerificationKey);
         account.AddClaim(ClaimTypes.Role, "Administrator");
         svc.Update(account);
     }
 }
        public void Init()
        {
            oldIterations = SecuritySettings.Instance.PasswordHashingIterationCount;
            SecuritySettings.Instance.PasswordHashingIterationCount = 1; // tests will run faster

            configuration = new MembershipRebootConfiguration();
            key = new KeyNotification();
            configuration.AddEventHandler(key);
            repository = new FakeUserAccountRepository();
            userAccountService = new UserAccountService(configuration, repository);

            subject = new TestAuthenticationService(userAccountService);
        }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this.userAccountService != null)
         {
             this.userAccountService.Dispose();
             this.userAccountService = null;
         }
         
         if (this.authSvc != null)
         {
             this.authSvc.Dispose();
             this.authSvc = null;
         }
     }
     base.Dispose(disposing);
 }
 public ChangeUsernameController(AuthenticationService authSvc)
 {
     this.userAccountService = authSvc.UserAccountService;
     this.authSvc = authSvc;
 }
 public PasswordResetController(UserAccountService userAccountService)
 {
     this.userAccountService = userAccountService;
 }
 public CloseAccountController(UserAccountService userAccountService)
 {
     this.userAccountService = userAccountService;
 }
 public ChangeSecretQuestionController(UserAccountService userAccountService)
 {
     this.userAccountService = userAccountService;
 }
 public ChangeMobileController(UserAccountService userAccountService, AuthenticationService authSvc)
 {
     this.userAccountService = userAccountService;
     this.authSvc = authSvc;
 }
 public LinkedAccountController(
     AuthenticationService AuthenticationService)
 {
     this.authenticationService = AuthenticationService;
     this.userAccountService = AuthenticationService.UserAccountService;
 }
 public void NullUserAccountRepo_Throws()
 {
     var sub = new UserAccountService(null, null, null);
 }
 public ChangeUsernameController(
     UserAccountService<CustomUserAccount> userAccountService, AuthenticationService<CustomUserAccount> authSvc)
 {
     this.userAccountService = userAccountService;
     this.authSvc = authSvc;
 }
 public ChangeSecretQuestionController(UserAccountService<HierarchicalUserAccount> userAccountService)
 {
     this.userAccountService = userAccountService;
 }
 public RegisterController(UserAccountService userAccountService)
 {
     this.userAccountService = userAccountService;
 }
 public PasswordResetController(AuthenticationService<HierarchicalUserAccount> authenticationService)
 {
     this.authenticationService = authenticationService;
     this.userAccountService = authenticationService.UserAccountService;
 }
 public HomeController(IUserAccountQuery query, UserAccountService<CustomUserAccount> userAccountService)
 {
     this.userAccountService = userAccountService;
     this.query = query;
 }
 public ChangePasswordController(UserAccountService userAccountService)
 {
     this.userAccountService = userAccountService;
 }