Esempio n. 1
0
        private void UpdateNewPasswordAwareTextBlock()
        {
            NewPasswordAwareMessage mes = NewPasswordAwareMessage.WhiteSpaceAware;

            if (NewPassword.Contains(" "))
            {
                NewPasswordAwareTextBlockVisibility = Visibility.Visible;
                mes = NewPasswordAwareMessage.WhiteSpaceAware;
            }
            else if (NewPassword.Equals(CurrentUser.Password))
            {
                NewPasswordAwareTextBlockVisibility = Visibility.Visible;
                mes = NewPasswordAwareMessage.SameBefore;
            }
            else if (NewPassword.Length < PharmacyDefinitions.MINIMUM_PASSWORD_LENGHT)
            {
                NewPasswordAwareTextBlockVisibility = Visibility.Visible;
                mes = NewPasswordAwareMessage.NotMeetLenght;
            }
            else if (NewPassword.IndexOfAny(PharmacyDefinitions.SPECIAL_CHARS_OF_PASSWORD) == -1)
            {
                NewPasswordAwareTextBlockVisibility = Visibility.Visible;
                mes = NewPasswordAwareMessage.WrongFormat;
            }
            else
            {
                NewPasswordAwareTextBlockVisibility = Visibility.Collapsed;
            }

            NewPasswordAwareTextBlockContent = mes.GetStringValue();
        }
Esempio n. 2
0
        public List <int> VerifyPassword(string password = null)
        {
            if (string.IsNullOrEmpty(NewPassword) || string.IsNullOrWhiteSpace(NewPassword) ||
                string.IsNullOrEmpty(PasswordConfirm) || string.IsNullOrWhiteSpace(PasswordConfirm))
            {
                return new List <int> {
                           0
                }
            }
            ;

            var errors = new List <int>();

            if (NewPassword != PasswordConfirm)
            {
                errors.Add(1);
            }

            var lenTest = new Regex(@".{6,20}");

            if (!lenTest.IsMatch(NewPassword))
            {
                errors.Add(2);
            }

            var lowTest = new Regex(@"[a-z]+");

            if (!lowTest.IsMatch(NewPassword))
            {
                errors.Add(3);
            }

            var capTest = new Regex(@"[A-Z]+");

            if (!capTest.IsMatch(NewPassword))
            {
                errors.Add(4);
            }

            var digitTest = new Regex(@"[\d]+");

            if (!digitTest.IsMatch(NewPassword))
            {
                errors.Add(5);
            }

            if (!errors.Contains(10) && NewPassword.Contains(" "))
            {
                errors.Add(6);
            }

            var spTest = new Regex(@"[!@#$%^&*_+\.]+");

            if (!spTest.IsMatch(NewPassword))
            {
                errors.Add(7);
            }

            return(errors);
        }
Esempio n. 3
0
        public bool Validate(bool create, User authorizedUser)
        {
            if (authorizedUser != null && authorizedUser.Id != Id)
            {
                return(authorizedUser.GetTeacher() != null && (NewRole.Equals("Teacher") || NewRole.Equals("Tutor")));
            }
            bool updateProof =
                Email != null && Identifier != null && Name != null && !Identifier.Contains("&") &&
                (NewPassword == null || !NewPassword.Contains("&")) &&
                (NewRole == null || NewRole.Equals("Teacher") || NewRole.Equals("Tutor") || NewRole.Equals("Student"));
            bool createProof =
                updateProof && NewPassword != null && NewRole != null;

            return(create ? createProof : updateProof);
        }
Esempio n. 4
0
        public List <int> VerifyNewPassword(string password = null)
        {
            if (!Helpers.IsProperString(NewPassword) ||
                !Helpers.IsProperString(NewPasswordConfirm)
                )
            {
                return new List <int> {
                           8
                }
            }
            ;

            var errors = new List <int>();

            if (NewPassword != NewPasswordConfirm)
            {
                errors.Add(9);
            }

            var lenTest = new Regex(@".{6,20}");

            if (!lenTest.IsMatch(NewPassword))
            {
                errors.Add(10);
            }

            var lowTest = new Regex(@"[a-z]+");

            if (!lowTest.IsMatch(NewPassword))
            {
                errors.Add(11);
            }

            var capTest = new Regex(@"[A-Z]+");

            if (!capTest.IsMatch(NewPassword))
            {
                errors.Add(12);
            }

            var digitTest = new Regex(@"[\d]+");

            if (!digitTest.IsMatch(NewPassword))
            {
                errors.Add(13);
            }

            if (!errors.Contains(10) && NewPassword.Contains(" "))
            {
                errors.Add(14);
            }

            var spTest = new Regex(@"[!@#$%^&*_+\.]+");

            if (!spTest.IsMatch(NewPassword))
            {
                errors.Add(15);
            }

            return(errors);
        }