Exemplo n.º 1
0
        public void Merge_Alerts()
        {
            Alerts part = new Alerts();

            part.AddError("SecondError");
            alerts.AddError("FirstError");

            IEnumerable <Alert> expected = alerts.Union(part);
            IEnumerable <Alert> actual   = alerts;

            alerts.Merge(part);

            Assert.Equal(expected, actual);
        }
Exemplo n.º 2
0
        public void OnActionExecuted_MergesTempDataAlerts()
        {
            Alerts alerts = new Alerts();

            alerts.AddError("Test1");

            controller.TempData["Alerts"] = JsonSerializer.Serialize(alerts);

            controller.Alerts.AddError("Test2");
            alerts.AddError("Test2");

            controller.OnActionExecuted(new ActionExecutedContext(action, new List <IFilterMetadata>(), null));

            Object expected = JsonSerializer.Serialize(alerts);
            Object actual   = controller.TempData["Alerts"];

            Assert.Equal(expected, actual);
        }
Exemplo n.º 3
0
        private Boolean IsActive(String? username)
        {
            Boolean isActive = UnitOfWork
                .Select<Account>()
                .Any(account =>
                    !account.IsLocked &&
                    account.Username.ToLower() == (username ?? "").ToLower());

            if (!isActive)
                Alerts.AddError(Validation.For<AccountView>("LockedAccount"));

            return isActive;
        }
Exemplo n.º 4
0
        private Boolean IsValidResetToken(String? token)
        {
            Boolean isValid = UnitOfWork
                .Select<Account>()
                .Any(account =>
                    account.RecoveryToken == token &&
                    account.RecoveryTokenExpirationDate > DateTime.Now);

            if (!isValid)
                Alerts.AddError(Validation.For<AccountView>("ExpiredToken"));

            return isValid;
        }
Exemplo n.º 5
0
        private Boolean IsActive(String username)
        {
            Boolean isActive = UnitOfWork
                               .Select <Account>()
                               .Any(account =>
                                    !account.IsLocked &&
                                    account.Username.ToLower() == username.ToLower());

            if (!isActive)
            {
                Alerts.AddError(Validations.LockedAccount);
            }

            return(isActive);
        }
Exemplo n.º 6
0
        private Boolean IsValidResetToken(String token)
        {
            Boolean isValid = UnitOfWork
                              .Select <Account>()
                              .Any(account =>
                                   account.RecoveryToken == token &&
                                   account.RecoveryTokenExpirationDate > DateTime.Now);

            if (!isValid)
            {
                Alerts.AddError(Validations.ExpiredToken);
            }

            return(isValid);
        }
        private Boolean IsActive(String username)
        {
            Boolean isActive = UnitOfWork
                               .Select <Account>()
                               .Any(account =>
                                    !account.IsLocked &&
                                    account.Username == username);

            if (!isActive)
            {
                Alerts.AddError(Validation.For <AccountView>("LockedAccount"));
            }

            return(isActive);
        }
Exemplo n.º 8
0
        private Boolean IsAuthenticated(String? username, String? password)
        {
            String? passhash = UnitOfWork
                .Select<Account>()
                .Where(account => account.Username.ToLower() == (username ?? "").ToLower())
                .Select(account => account.Passhash)
                .SingleOrDefault();

            Boolean isCorrect = Hasher.VerifyPassword(password, passhash);

            if (!isCorrect)
                Alerts.AddError(Validation.For<AccountView>("IncorrectAuthentication"));

            return isCorrect;
        }
Exemplo n.º 9
0
        private Boolean IsAuthenticated(String username, String password)
        {
            String passhash = UnitOfWork
                              .Select <Account>()
                              .Where(account => account.Username.ToLower() == username.ToLower())
                              .Select(account => account.Passhash)
                              .SingleOrDefault();

            Boolean isCorrect = Hasher.VerifyPassword(password, passhash);

            if (!isCorrect)
            {
                Alerts.AddError(Validations.IncorrectAuthentication);
            }

            return(isCorrect);
        }