Example #1
0
        public bool ValidateUserInput(out User user)
        {
            user = null;
            if (this.userName.Equals(string.Empty) || this.password.Equals(string.Empty))
            {
                errorMessage = "Username or password is empty";
                actionOnError(errorMessage);
                CurrentUserRole = UserRoles.Roles.Anonymous;
                return(false);
            }

            if (this.userName.Length < 5 || this.password.Length < 5)
            {
                errorMessage = "Username or password shoud be at least 5 characters long";
                actionOnError(errorMessage);
                CurrentUserRole = UserRoles.Roles.Anonymous;
                return(false);
            }

            user = UserData.IsUserPasswordCorrect(this.userName, this.password);

            if (user == null)
            {
                errorMessage = "User with that username and password is not found";
                actionOnError(errorMessage);
                CurrentUserRole = UserRoles.Roles.Anonymous;
                return(false);
            }
            CurrentUserRole = (UserRoles.Roles)user.UserRole;
            CurrentUserName = user.UserName;
            Logger.LogActivity("Successfull login");
            return(true);
        }