Exemplo n.º 1
0
        private static void CheckForFatalCredentialingProblems(string usernameEntered)
        {
            switch (UserSecurityClass)
            {
            case MasterSecurityClass:
                // no additional info needed
                break;

            case StateAdminSecurityClass:
                if (!StateCache.IsValidStateCode(UserStateCode))
                {
                    HandleCredentialingInconsistency(usernameEntered, "Invalid StateCode");
                }
                break;

            case CountyAdminSecurityClass:
                if (!Counties.StateCodeCountyCodeExists(UserStateCode, UserCountyCode))
                {
                    HandleCredentialingInconsistency(usernameEntered, "Invalid CountyCode");
                }
                break;

            case LocalAdminSecurityClass:
                //if (!LocalDistricts.StateCodeCountyCodeLocalCodeExists(
                // UserStateCode, UserCountyCode, UserLocalCode))
                //  HandleCredentialingInconsistency(usernameEntered, "Invalid LocalCode");
                break;

            case PartySecurityClass:
                if (!Parties.PartyKeyExists(UserPartyKey))
                {
                    HandleCredentialingInconsistency(usernameEntered, "Invalid PartyKey");
                }
                break;

            case PoliticianSecurityClass:
                // no additional info needed --
                // they couldn't get this far without a valid politician key
                break;

            case DesignSecurityClass:
                if (!DomainDesigns.DomainDesignCodeExists(UserDesignCode))
                {
                    HandleCredentialingInconsistency(usernameEntered, "Invalid DesignCode");
                }
                break;

            case OrganizationSecurityClass:
                if (!Organizations.OrganizationCodeExists(UserOrganizationCode))
                {
                    HandleCredentialingInconsistency(
                        usernameEntered, "Invalid OrganizationCode");
                }
                break;
            }
        }
Exemplo n.º 2
0
        protected override void OnPreLoad(EventArgs e)
        {
            base.OnPreLoad(e);
            StateCode       = FindStateCode();
            CountyCode      = FindCountyCode();
            LocalKey        = FindLocalKey();
            StateCodeExists = StateCache.IsValidStateCode(StateCode);
            if (StateCodeExists)
            {
                StateCodeIsNonState = false;
                if (IsNullOrWhiteSpace(CountyCode))
                {
                    AdminPageLevel = AdminPageLevel.State;
                    CodesAreValid  = true;
                }
                else // we have a CountyCode
                {
                    AdminPageLevel   = AdminPageLevel.County;
                    CountyCodeExists = Counties.StateCodeCountyCodeExists(StateCode,
                                                                          CountyCode);
                    if (CountyCodeExists)
                    {
                        if (IsNullOrWhiteSpace(LocalKey))
                        {
                            CodesAreValid = true;
                        }
                        else
                        {
                            AdminPageLevel = AdminPageLevel.Local;
                            LocalKeyExists = LocalDistricts.StateCodeLocalKeyExists(StateCode, LocalKey);
                            CodesAreValid  = LocalKeyExists;
                        }
                    }
                }
            }
            else
            {
                var nonStateCodesAllowed          = NonStateCodesAllowed;
                var nonStateCodesRequireSuperUser = NonStateCodesRequireSuperUser;
                if (nonStateCodesAllowed != null &&
                    nonStateCodesAllowed.Contains(StateCode) &&
                    (IsSuperUser || nonStateCodesRequireSuperUser == null ||
                     !nonStateCodesRequireSuperUser.Contains(StateCode)))
                {
                    StateCodeExists = true;
                    CodesAreValid   = true;
                    switch (StateCode)
                    {
                    case "US":
                        AdminPageLevel = AdminPageLevel.President;
                        break;

                    case "PP":
                        AdminPageLevel = AdminPageLevel.PresidentTemplate;
                        break;

                    case "U1":
                    case "U2":
                    case "U3":
                    case "U4":
                        AdminPageLevel = AdminPageLevel.Federal;
                        break;

                    case "":
                    case "LL":
                        AdminPageLevel = AdminPageLevel.AllStates;
                        break;

                    default:
                        StateCodeExists = false;
                        CodesAreValid   = false;
                        break;
                    }
                }
            }
        }