Exemple #1
0
        //*****************USERS **********************************
        public static int CreateT_OE_USERS(global::System.String uSER_ID, global::System.String pWD_HASH, global::System.String pWD_SALT, global::System.String fNAME, global::System.String lNAME, global::System.String eMAIL, global::System.Boolean aCT_IND, global::System.Boolean iNITAL_PWD_FLAG, global::System.DateTime?lASTLOGIN_DT, global::System.String pHONE, global::System.String pHONE_EXT, global::System.String cREATE_USER)
        {
            using (OpenEnvironmentEntities ctx = new OpenEnvironmentEntities())
            {
                try
                {
                    T_OE_USERS u = new T_OE_USERS();
                    u.USER_ID         = uSER_ID;
                    u.PWD_HASH        = pWD_HASH;
                    u.PWD_SALT        = pWD_SALT;
                    u.FNAME           = fNAME;
                    u.LNAME           = lNAME;
                    u.EMAIL           = eMAIL;
                    u.ACT_IND         = aCT_IND;
                    u.INITAL_PWD_FLAG = iNITAL_PWD_FLAG;
                    u.EFFECTIVE_DT    = System.DateTime.Now;
                    u.LASTLOGIN_DT    = lASTLOGIN_DT;
                    u.PHONE           = pHONE;
                    u.PHONE_EXT       = pHONE_EXT;
                    u.CREATE_DT       = System.DateTime.Now;
                    u.CREATE_USERID   = cREATE_USER;

                    ctx.AddToT_OE_USERS(u);
                    ctx.SaveChanges();
                    return(u.USER_IDX);
                }
                catch (Exception ex)
                {
                    return(0);
                }
            }
        }
Exemple #2
0
        public ActionResult Login(vmAccountLogin model, string returnUrl)
        {
            Session.Clear();

            if (ModelState.IsValid)
            {
                if (Membership.ValidateUser(model.UserName, model.Password))
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);

                    T_OE_USERS u = db_Accounts.GetT_OE_USERSByID(model.UserName);
                    if (u.INITAL_PWD_FLAG)
                    {
                        return(RedirectToAction("SetPermPassword"));
                    }
                    else
                    {
                        db_Accounts.UpdateT_OE_USERS(u.USER_IDX, null, null, null, null, null, null, null, null, System.DateTime.Now, null, null, null, null, null, null);
                        return(RedirectToAction("Index", "Dashboard"));
                    }
                }
            }

            // If we got this far, something failed, redisplay form
            TempData["Error"] = "The user name or password provided is incorrect.";
            //ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return(View(model));
        }
Exemple #3
0
        public ActionResult SetPermPassword(vmAccountChangePassword model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    T_OE_USERS u = db_Accounts.GetT_OE_USERSByIDX(db_Accounts.GetUserIDX());
                    if (u != null)
                    {
                        if (Membership.ValidateUser(u.USER_ID, model.OldPassword) == true)
                        {
                            if (Membership.Provider.ChangePassword(u.USER_ID, model.OldPassword, model.Password))
                            {
                                FormsAuthentication.SetAuthCookie(u.USER_ID, true);
                                return(RedirectToAction("Index", "Dashboard"));
                            }
                        }
                    }
                }
                catch { }
            }

            //if got this far, failed
            TempData["Error"] = "Change password failed.";
            return(View(model));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int        UserIDX = Utils.GetUserIDX(User);
                T_OE_USERS u       = db_Accounts.GetT_OE_USERSByIDX(UserIDX);
                if (u != null)
                {
                    txtUserName.Text = u.USER_ID;
                    txtFName.Text    = u.FNAME;
                    txtLName.Text    = u.LNAME;
                    txtEmail.Text    = u.EMAIL;
                    txtPhone.Text    = u.PHONE;
                }


                //populate listing of Roles
                lbRoleList.Items.Clear();
                string[] rolelist = System.Web.Security.Roles.GetRolesForUser();
                foreach (string s in rolelist)
                {
                    lbRoleList.Items.Add(s);
                }

                //populate listing of Organizations
                lblOrgList.Items.Clear();
                List <T_WQX_ORGANIZATION> orgs = db_WQX.GetWQX_USER_ORGS_ByUserIDX(UserIDX, true);
                foreach (T_WQX_ORGANIZATION org in orgs)
                {
                    lblOrgList.Items.Add(org.ORG_FORMAL_NAME);
                }
            }
        }
Exemple #5
0
        public ActionResult AgencyUserFlagRemoval(vmDashboardAgency model)
        {
            if (model.FlagUserIDX != null && model.agency.ORG_IDX != null)
            {
                //get flagging user
                int        UserIDX      = db_Accounts.GetUserIDX();
                T_OE_USERS flaggingUser = db_Accounts.GetT_OE_USERSByIDX(UserIDX);

                //get flagged user
                T_OE_USERS flaggedUser = db_Accounts.GetT_OE_USERSByIDX(model.FlagUserIDX.GetValueOrDefault());


                //notify Site Admins via email
                List <T_OE_USERS> Admins = db_Accounts.GetT_OE_USERSInRole(1);
                foreach (T_OE_USERS Admin in Admins)
                {
                    Utils.SendEmail(null, Admin.EMAIL, null, null, "EECIP: " + flaggedUser.FNAME + ' ' + flaggedUser.LNAME + " flagged for removal", "The user " + flaggedUser.FNAME + ' ' + flaggedUser.LNAME + " (" + flaggedUser.EMAIL + ") has been flagged for removal by the EECIP user " + flaggedUser.FNAME + ' ' + flaggedUser.LNAME + ". Please log into EECIP and consider removing or inactivating the user account", null, null, null);
                }

                TempData["Success"] = "Your request has been submitted.";
            }
            else
            {
                TempData["Error"] = "Unable to make request at this time.";
            }


            return(RedirectToAction("Agency", "Dashboard"));
        }
Exemple #6
0
        public static void SetOrgSessionID(string UserID, string url)
        {
            T_OE_USERS u = GetT_OE_USERSByID(UserID);

            if (u != null)
            {
                if (u.DEFAULT_ORG_ID == null)
                {
                    List <T_WQX_ORGANIZATION> os = db_WQX.GetWQX_USER_ORGS_ByUserIDX(u.USER_IDX, false);
                    //if user only belongs to 1 org, update the default org id
                    if (os.Count == 1)
                    {
                        UpdateT_OE_USERSDefaultOrg(u.USER_IDX, os[0].ORG_ID);
                        HttpContext.Current.Session["OrgID"] = os[0].ORG_ID;
                    }
                    else if (os.Count > 1)
                    {
                        HttpContext.Current.Response.Redirect("~/App_Pages/Secure/SetOrg.aspx?ReturnUrl=" + url);
                    }
                    else if (os.Count == 0)
                    {
                        HttpContext.Current.Response.Redirect("~/App_Pages/Secure/WQXOrgNew.aspx");
                    }
                }
                else
                {
                    HttpContext.Current.Session["OrgID"] = u.DEFAULT_ORG_ID;
                }
            }
        }
Exemple #7
0
        public ActionResult Unsubscribe(int?ux, string key)
        {
            T_OE_USERS u = db_Accounts.GetT_OE_USERSByIDX(ux ?? -1);

            if (u != null)
            {
                //decrypt oauth string
                string oauthDecode = HttpUtility.UrlDecode(key);
                oauthDecode = oauthDecode.Replace(" ", "+");   //fix situations where spaces and plus get mixed up
                string decryptStr = new SimpleAES().Decrypt(oauthDecode);

                if (decryptStr == u.PWD_HASH)
                {
                    //unsubscribe from newsletter
                    db_Accounts.UpdateT_OE_USERS(u.USER_IDX, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
                                                 null, null, null, null, false);

                    TempData["Success"] = "You have successfully unsubscribed.";
                }
                else
                {
                    TempData["Error"] = "Unable to unsubscribe.";
                }
            }
            else
            {
                TempData["Error"] = "Unable to unsubscribe.";
            }

            return(View());
        }
        // GET: Dashboard
        public ActionResult Index()
        {
            int UserIDX = db_Accounts.GetUserIDX();

            var model = new vmDashboardIndex();

            model.UserBadges = db_Forum.GetBadgesForUser(UserIDX);                                                 //badge progress
            model.ProjectsNeedingReviewCount = db_EECIP.GetT_OE_PROJECTS_NeedingReviewCount(UserIDX);              //projects needing review
            model.UserPointLeaders           = db_Forum.GetMembershipUserPoints_MostPoints(6);                     //user point leaders
            model.LatestProjects             = db_EECIP.GetT_OE_PROJECTS_RecentlyUpdatedMatchingInterest(UserIDX); //latest projects
            model.LatestTopics         = db_Forum.GetLatestTopicPostsMatchingInterest(UserIDX);                    //latest topics matching interest
            model.ProjectCount         = db_EECIP.GetT_OE_PROJECTS_CountNonGovernance();
            model.GovernanceCount      = db_EECIP.GetT_OE_PROJECTS_CountGovernance();
            model.DiscussionCount      = db_Forum.GetTopicCount();
            model.AgencyCount          = db_Ref.GetT_OE_ORGANIZATION_Count();
            model.UserBadgeEarnedCount = db_Forum.GetBadgesForUserCount(UserIDX);
            model.Announcement         = db_Ref.GetT_OE_APP_SETTING_CUSTOM().ANNOUNCEMENTS;
            T_OE_USERS u = db_Accounts.GetT_OE_USERSByIDX(UserIDX);

            if (u != null)
            {
                model.UserName = u.FNAME + " " + u.LNAME;
            }
            return(View(model));
        }
        public ActionResult EnterpriseSvcCard(string strid)
        {
            int UserIDX = strid.ConvertOrDefault <int>();
            int id      = strid.ConvertOrDefault <int>();

            if (id > 100000)
            {
                id = id - 100000;
            }

            var model = new vmDashboardEntSvcCard();

            model.entsvc = db_EECIP.GetT_OE_ORGANIZATION_ENT_SVCS_ByID(id);
            if (model.entsvc != null)
            {
                T_OE_ORGANIZATION _org = db_Ref.GetT_OE_ORGANIZATION_ByID(model.entsvc.ORG_IDX.ConvertOrDefault <Guid>());
                if (_org != null)
                {
                    model.OrgName = _org.ORG_NAME;
                }

                T_OE_USERS u = db_Accounts.GetT_OE_USERSByIDX(model.entsvc.MODIFY_USERIDX ?? model.entsvc.CREATE_USERIDX ?? -1);
                if (u != null)
                {
                    model.LastUpdatedUser = u.FNAME + " " + u.LNAME;
                }
            }
            //model.User = db_Accounts.GetT_OE_USERSByIDX(UserIDX);
            //model.UserOrg = db_Ref.GetT_OE_ORGANIZATION_ByID(model.User.ORG_IDX.ConvertOrDefault<Guid>());

            //            if (model.User != null)
            return(View(model));

            //return RedirectToAction("Index", "Dashboard");
        }
        public ActionResult Governance(Guid?selAgency)
        {
            int UserIDX = db_Accounts.GetUserIDX();

            var model = new vmDashboardGovernance();

            T_OE_USERS user = db_Accounts.GetT_OE_USERSByIDX(UserIDX);

            if (user != null)
            {
                model.UnlockedInd = user.ALLOW_GOVERNANCE;

                //if user has unlocked governance, display more
                if (model.UnlockedInd == true)
                {
                    if (selAgency != null)
                    {
                        model.selAgency = selAgency;
                        model.projects  = db_EECIP.GetT_OE_PROJECTS_ByOrgIDX(selAgency.ConvertOrDefault <Guid>());

                        T_OE_ORGANIZATION o = db_Ref.GetT_OE_ORGANIZATION_ByID(selAgency.ConvertOrDefault <Guid>());
                        if (o != null)
                        {
                            model.selAgencyName = o.ORG_NAME;
                        }
                    }
                }
            }

            return(View(model));
        }
Exemple #11
0
        public override bool ValidateUser(string username, string password)
        {
            //check if password matches hashed/salted password
            T_OE_USERS u = db_Accounts.GetT_OE_USERSByID(username);

            if (u != null)
            {
                if (u.ACT_IND == false)
                {
                    return(false); //fail if user is inactive
                }
                if (CheckPassword(password, u.PWD_HASH, u.PWD_SALT))
                {
                    return(true);
                }
                else
                {
                    db_Accounts.UpdateT_OE_USERS(u.USER_IDX, null, null, null, null, null, u.LOG_ATMPT.ConvertOrDefault <int>() < MaxInvalidPasswordAttempts, null, null, null, null, null, null, u.LOG_ATMPT.ConvertOrDefault <int>() + 1, null, null);

                    //user account is locked due to too many invalid login attempts
                    if (u.LOG_ATMPT.ConvertOrDefault <int>() + 1 > MaxInvalidPasswordAttempts)
                    {
                        Utils.SendEmail(null, u.EMAIL, null, null, "EECIP account locked.", "Your EECIP user account has been locked due to too many incorrect login attempts. Please contact the system administrator to reset your user account.", null, "");
                    }

                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        // GET: /Account/UserProfile/2
        public ActionResult UserProfile(int?id, string a)
        {
            if (id == null)
            {
                id = db_Accounts.GetUserIDX();
            }

            //security validation: only admins can (only allow site admin or user to edit their own profile)
            if (!User.IsInRole("Admins") && a == "a")
            {
                return(RedirectToAction("AccessDenied", "Home"));
            }

            //security validation (only allow site admin or user to edit their own profile)
            if ((!User.IsInRole("Admins")) && (id != db_Accounts.GetUserIDX()))
            {
                return(RedirectToAction("AccessDenied", "Home"));
            }


            var        model = new vmAccountUserProfile();
            T_OE_USERS u     = db_Accounts.GetT_OE_USERSByIDX(id ?? 0);

            if (u != null)
            {
                model.UserIDX        = u.USER_IDX;
                model.UserID         = u.USER_ID;
                model.FName          = u.FNAME;
                model.LName          = u.LNAME;
                model.Email          = u.EMAIL;
                model.Phone          = u.PHONE;
                model.PhoneExt       = u.PHONE_EXT;
                model.OrgIDX         = u.ORG_IDX;
                model.JobTitle       = u.JOB_TITLE;
                model.LinkedIn       = u.LINKEDIN;
                model.NodeAdmin      = u.NODE_ADMIN;
                model.HasAvatar      = (u.USER_AVATAR != null);
                model.ImageUniqueStr = (u.MODIFY_DT ?? u.CREATE_DT).ConvertOrDefault <DateTime>().Ticks.ToString();
                model.ActInd         = u.ACT_IND;
                model.uListInd       = a;
                model.ExcludeBadges  = u.EXCLUDE_POINTS_IND;


                //expertise
                model.SelectedExpertise = db_EECIP.GetT_OE_USER_EXPERTISE_ByUserIDX(id ?? 0);
                model.AllExpertise      = db_EECIP.GetT_OE_USER_EXPERTISE_ByUserIDX_All(id ?? 0).Select(x => new SelectListItem {
                    Value = x, Text = x
                });

                //org name
                T_OE_ORGANIZATION org = db_Ref.GetT_OE_ORGANIZATION_ByID(model.OrgIDX.ConvertOrDefault <Guid>());
                if (org != null)
                {
                    model.OrgName = org.ORG_NAME;
                }
            }

            return(View(model));
        }
        public override string ResetPassword(string username, string answer)
        {
            T_OE_USERS u = db_Accounts.GetT_OE_USERSByID(username);

            if (u != null)
            {
                //generate new password
                string newPass  = RandomString(10);
                string salt     = GenerateSalt();
                string hashpass = HashPassword(newPass, _PasswordFormat, salt);

                //save updated hashed password and salt
                if (db_Accounts.UpdateT_OE_USERS(u.USER_IDX, hashpass, salt, null, null, null, null, true, null, null, null, null, null, 0, null, null, null, null, null, null, null, null) == 1)
                {
                    //encrypt username for email
                    string encryptOauth = new SimpleAES().Encrypt(newPass + "||" + username);
                    encryptOauth = System.Web.HttpUtility.UrlEncode(encryptOauth);

                    //send verification email to user
                    string msg = "Your EECIP password has been reset."
                                 + "\r\n\r\n Your username is: " + username
                                 + "\r\n\r\n You must click the following link to set your permanent password: "******"\r\n\r\n " + db_Ref.GetT_OE_APP_SETTING("PUBLIC_APP_PATH") + "/Account/Verify?oauthcrd=" + encryptOauth
                                 + "\r\n\r\n "
                                 + "\r\n\r\n ABOUT EECIP"
                                 + "\r\n\r\n ----------"
                                 + "\r\n\r\n The E - Enterprise Community Inventory Platform (EECIP) is an online community and living project inventory for state, local, tribal, and other environmental agencies and their employees across the United States. This tool was developed under the E-Enterprise for the Environment initiative to support state, tribal, and U.S. EPA staff working to modernize the business of environmental protection.";


                    //send verification email to user
                    string messageHTML = "<p><b>Your EECIP password has been reset.</b></p>"
                                         + "<p>Your username is: " + username + "</p>"
                                         + "<p>You must click the following link to set your permanent password: </p>"
                                         + "<p><a href='" + db_Ref.GetT_OE_APP_SETTING("PUBLIC_APP_PATH") + "/Account/Verify?oauthcrd=" + encryptOauth + "'>Click Verification Link</a></p>"
                                         + "<p></p>"
                                         + "<p>ABOUT EECIP</p>"
                                         + "<p>----------</p>"
                                         + "<p>The E - Enterprise Community Inventory Platform (EECIP) is an online community and living project inventory for state, local, tribal, and other environmental agencies and their employees across the United States. This tool was developed under the E-Enterprise for the Environment initiative to support state, tribal, and U.S. EPA staff working to modernize the business of environmental protection.</p>";


                    if (Utils.SendEmail(null, u.EMAIL, null, null, "EECIP Password Reset", msg, null, "", messageHTML))
                    {
                        return("Success: Please check your email for password reset instructions.");
                    }
                    else
                    {
                        return("Error in sending email");
                    }
                }
                else
                {
                    return("Error resetting password");
                }
            }
            else
            {
                return("Error: Email does not exist in the system.");
            }
        }
Exemple #14
0
        public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
        {
            T_OE_USERS u = db_Accounts.GetT_OE_USERSByIDX((int)providerUserKey);

            var newCreateDate = u.CREATE_DT ?? System.DateTime.Now;
            var newModifyDate = u.MODIFY_DT ?? System.DateTime.Now;

            return(new MembershipUser(this.Name, u.USER_ID, u.USER_IDX, u.EMAIL, null, null, true, false, newCreateDate, newModifyDate, newModifyDate, newModifyDate, newModifyDate));
        }
Exemple #15
0
        public override bool ChangePassword(string username, string oldPassword, string newPassword)
        {
            //validate new password length
            if (newPassword == null)
            {
                return(false);
            }

            if (newPassword.Length < _MinRequiredPasswordLength)
            {
                return(false);
            }

            //Validate Non-AlphaNumeric characters
            char[] charpwd            = newPassword.ToCharArray();
            int    pwdNonNumericCount = 0;

            for (int i = 1; i < newPassword.Length; i++)
            {
                if (!char.IsLetterOrDigit(charpwd[i]))
                {
                    pwdNonNumericCount += 1;
                }
            }

            if (pwdNonNumericCount < _MinRequiredNonalphanumericCharacters)
            {
                return(false);
            }

            T_OE_USERS u = db_Accounts.GetT_OE_USERSByID(username);

            if (u != null)
            {
                //first check accuracy of old password
                if (!CheckPassword(oldPassword, u.PWD_HASH, u.PWD_SALT))
                {
                    return(false);
                }

                //generate new password
                string salt     = GenerateSalt();
                string hashpass = HashPassword(newPassword, _PasswordFormat, salt);
                //save updated information
                if (db_Accounts.UpdateT_OE_USERS(u.USER_IDX, hashpass, salt, null, null, null, null, false, null, null, null, null, 0, null, null, null) == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
        public override bool ChangePassword(string username, string oldPassword, string newPassword)
        {
            //validate new password length
            if (!Utils.ValidateParameter(ref newPassword, true, true, false, 0, _MinRequiredPasswordLength))
            {
                return(false);
            }

            //Validate Non-AlphaNumeric characters
            char[] charpwd            = newPassword.ToCharArray();
            int    pwdNonNumericCount = 0;

            for (int i = 1; i < newPassword.Length; i++)
            {
                if (!char.IsLetterOrDigit(charpwd[i]))
                {
                    pwdNonNumericCount += 1;
                }
            }

            if (pwdNonNumericCount < _MinRequiredNonalphanumericCharacters)
            {
                return(false);
            }


            using (OpenEnvironmentEntities context = new OpenEnvironmentEntities())
            {
                T_OE_USERS u = db_Accounts.GetT_OE_USERSByID(username);
                if (u != null)
                {
                    //first check accuracy of old password
                    if (!CheckPassword(oldPassword, u.PWD_HASH, u.PWD_SALT))
                    {
                        return(false);
                    }

                    //generate new password
                    string salt     = GenerateSalt();
                    string hashpass = HashPassword(newPassword, MembershipPasswordFormat.Hashed, salt);
                    //save updated information
                    if (db_Accounts.UpdateT_OE_USERS(u.USER_IDX, hashpass, salt, null, null, null, null, false, null, null, null, null, "system") > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
        public override string GetUserNameByEmail(string email)
        {
            T_OE_USERS u = db_Accounts.GetT_VCCB_USERByEmail(email);

            if (u != null)
            {
                return(u.USER_ID);
            }
            else
            {
                return(null);
            }
        }
Exemple #18
0
        public ActionResult CreatePost(vmForumTopicView model)
        {
            int UserIDX = db_Accounts.GetUserIDX();

            // ************************ VALIDATION **********************************************
            // Check posting flood control
            if (!db_Forum.PassedPostFloodTest(UserIDX))
            {
                TempData["Error"] = "Please wait at least 30 seconds between posts";
                return(RedirectToAction("ShowTopic", new { slug = model.Topic.Slug }));
            }

            // Log user out if they are LockedOut but still authenticated
            T_OE_USERS u = db_Accounts.GetT_OE_USERSByIDX(UserIDX);

            if (u != null && u.LOCKOUT_ENABLED)
            {
                FormsAuthentication.SignOut();
                return(RedirectToAction("Index", "Home"));
            }

            //required fields
            if (model.NewPostContent == null)
            {
                TempData["Error"] = "You must supply post content.";
                return(RedirectToAction("ShowTopic", new { slug = model.Topic.Slug }));
            }
            // ************************ END VALIDATION **********************************************


            Guid?_postID = db_Forum.InsertUpdatePost(null, model.NewPostContent, null, null, false, false, false, null, null, model.Topic.Id, UserIDX, false);

            if (_postID != null)
            {
                //set topic last post date
                db_Forum.UpdateTopic_SetLastPostDate(model.Topic.Id, null);

                // Success send any notifications
                NotifyTopics(model.Topic.Id, UserIDX, "Post");

                // 4. Update the users points score for posting
                db_Forum.InsertUpdateMembershipUserPoints(null, 1, System.DateTime.UtcNow, 0, _postID, null, UserIDX);

                // Update Azure search
                AzureSearch.PopulateSearchIndexForumPost(_postID);
            }


            // Return view
            return(RedirectToAction("ShowTopic", "Forum", new { slug = model.Topic.Slug }));
        }
Exemple #19
0
        public static void PostLoginUser(string UserID)
        {
            T_OE_USERS u = db_Accounts.GetT_OE_USERSByID(UserID);

            if (u != null)
            {
                //if user only belongs to 1 org, update the default org id
                if (u.DEFAULT_ORG_ID == null)
                {
                    List <T_WQX_ORGANIZATION> os = db_WQX.GetWQX_USER_ORGS_ByUserIDX(u.USER_IDX, false);
                    if (os.Count == 1)
                    {
                        db_Accounts.UpdateT_OE_USERSDefaultOrg(u.USER_IDX, os[0].ORG_ID);
                        HttpContext.Current.Session["OrgID"] = os[0].ORG_ID; //added 1/6/2014
                    }
                }

                if (u.INITAL_PWD_FLAG == false)
                {
                    db_Accounts.UpdateT_OE_USERS(u.USER_IDX, null, null, null, null, null, null, null, null, System.DateTime.Now, null, null, "system");

                    //set important session variables
                    HttpContext.Current.Session["UserIDX"]                  = u.USER_IDX;
                    HttpContext.Current.Session["OrgID"]                    = u.DEFAULT_ORG_ID; //added 1/6/2014
                    HttpContext.Current.Session["MLOC_HUC_EIGHT"]           = false;
                    HttpContext.Current.Session["MLOC_HUC_TWELVE"]          = false;
                    HttpContext.Current.Session["MLOC_TRIBAL_LAND"]         = false;
                    HttpContext.Current.Session["MLOC_SOURCE_MAP_SCALE"]    = false;
                    HttpContext.Current.Session["MLOC_HORIZ_COLL_METHOD"]   = true;
                    HttpContext.Current.Session["MLOC_HORIZ_REF_DATUM"]     = true;
                    HttpContext.Current.Session["MLOC_VERT_MEASURE"]        = false;
                    HttpContext.Current.Session["MLOC_COUNTRY_CODE"]        = true;
                    HttpContext.Current.Session["MLOC_STATE_CODE"]          = true;
                    HttpContext.Current.Session["MLOC_COUNTY_CODE"]         = true;
                    HttpContext.Current.Session["MLOC_WELL_DATA"]           = false;
                    HttpContext.Current.Session["MLOC_WELL_TYPE"]           = false;
                    HttpContext.Current.Session["MLOC_AQUIFER_NAME"]        = false;
                    HttpContext.Current.Session["MLOC_FORMATION_TYPE"]      = false;
                    HttpContext.Current.Session["MLOC_WELLHOLE_DEPTH"]      = false;
                    HttpContext.Current.Session["PROJ_SAMP_DESIGN_TYPE_CD"] = false;
                    HttpContext.Current.Session["PROJ_QAPP_APPROVAL"]       = false;
                    HttpContext.Current.Session["SAMP_ACT_END_DT"]          = false;
                    HttpContext.Current.Session["SAMP_COLL_METHOD"]         = false;
                    HttpContext.Current.Session["SAMP_COLL_EQUIP"]          = false;
                    HttpContext.Current.Session["SAMP_PREP"]                = false;
                    HttpContext.Current.Session["SAMP_DEPTH"]               = false;
                }
            }
        }
Exemple #20
0
        public override string ResetPassword(string username, string answer)
        {
            T_OE_USERS u = db_Accounts.GetT_OE_USERSByID(username);

            if (u != null)
            {
                //generate new password
                string newPass  = RandomString(10);
                string salt     = GenerateSalt();
                string hashpass = HashPassword(newPass, _PasswordFormat, salt);

                //save updated hashed password and salt
                if (db_Accounts.UpdateT_OE_USERS(u.USER_IDX, hashpass, salt, null, null, null, null, true, null, null, null, null, null, 0, null, null) == 1)
                {
                    //encrypt username for email
                    string encryptOauth = new SimpleAES().Encrypt(newPass + "||" + username);
                    encryptOauth = System.Web.HttpUtility.UrlEncode(encryptOauth);

                    //send verification email to user
                    string msg = "Your EECIP password has been reset."
                                 + "\r\n\r\n Your username is: " + username
                                 + "\r\n\r\n You must click the following link to set your permanent password: "******"\r\n\r\n " + db_Ref.GetT_OE_APP_SETTING("PUBLIC_APP_PATH") + "/Account/Verify?oauthcrd=" + encryptOauth;

                    //send verification email to user
                    string messageHTML = "<p><b>Your EECIP password has been reset.</b></p>"
                                         + "<p>Your username is: " + username + "</p>"
                                         + "<p>You must click the following link to set your permanent password: </p>"
                                         + "<p><a href='" + db_Ref.GetT_OE_APP_SETTING("PUBLIC_APP_PATH") + "/Account/Verify?oauthcrd=" + encryptOauth + "'>Click Verification Link</a></p>";

                    if (Utils.SendEmail(null, u.EMAIL, null, null, "EECIP Password Reset", msg, null, "", messageHTML))
                    {
                        return("Success: Please check your email for password reset instructions.");
                    }
                    else
                    {
                        return("Error in sending email");
                    }
                }
                else
                {
                    return("Error resetting password");
                }
            }
            else
            {
                return("Error: Email does not exist in the system.");
            }
        }
Exemple #21
0
        private void LogIn(string UserID)
        {
            LoginUser.DestinationPageUrl = "~/App_Pages/Secure/Dashboard.aspx";

            T_OE_USERS u = db_Accounts.GetT_OE_USERSByID(UserID);

            if (u != null)
            {
                if (u.INITAL_PWD_FLAG)
                {
                    LoginUser.DestinationPageUrl = "~/Account/ChangePassword.aspx?t=ini";
                }
            }

            Utils.PostLoginUser(UserID);
        }
Exemple #22
0
        // GET: Projects
        public ActionResult Projects()
        {
            // get the agency for which the logged in user is associated
            T_OE_USERS u = db_Accounts.GetT_OE_USERSByIDX(db_Accounts.GetUserIDX());

            if (u != null && u.ORG_IDX != null)
            {
                var model = new vmDashboardProjects();
                model.projects = db_EECIP.GetT_OE_PROJECTS_ByOrgIDX(u.ORG_IDX.ConvertOrDefault <Guid>());

                return(View(model));
            }

            TempData["Error"] = "You are not associated with an agency.";
            return(RedirectToAction("AccessDenied", "Home"));
        }
Exemple #23
0
        public override MembershipUser GetUser(string username, bool userIsOnline)
        {
            T_OE_USERS u = db_Accounts.GetT_OE_USERSByID(username);

            if (u != null)
            {
                var newCreateDate = u.CREATE_DT ?? System.DateTime.Now;
                var newModifyDate = u.MODIFY_DT ?? System.DateTime.Now;

                return(new MembershipUser(this.Name, u.USER_ID, u.USER_IDX, u.EMAIL, null, null, true, false, newCreateDate, newModifyDate, newModifyDate, newModifyDate, newModifyDate));
            }
            else
            {
                return(null);
            }
        }
Exemple #24
0
        // GET: Account/Login
        public ActionResult Login(string returnUrl)
        {
            //auto pass forward to dashboard if logged in
            T_OE_USERS u = db_Accounts.GetT_OE_USERSByID(User.Identity.Name);

            if (u != null)
            {
                if (u.ACT_IND == true)
                {
                    return(RedirectToAction("Index", "Dashboard"));
                }
            }

            ViewBag.ReturnUrl = returnUrl;
            return(View("Login"));
        }
        // GET: /Dashboard/Agency
        public ActionResult Agency(Guid?selAgency)
        {
            int UserIDX = db_Accounts.GetUserIDX();

            if (selAgency == null || selAgency == Guid.Empty)
            {
                // get agency for which the logged in user is associated
                T_OE_USERS u = db_Accounts.GetT_OE_USERSByIDX(UserIDX);
                if (u != null && u.ORG_IDX != null)
                {
                    selAgency = u.ORG_IDX.ConvertOrDefault <Guid>();
                }
            }

            //if still no agency
            if (selAgency == null || selAgency == Guid.Empty)
            {
                TempData["Error"] = "You are not associated with an agency.";
                return(RedirectToAction("AccessDenied", "Home"));
            }

            if (!User.IsInRole("Admins") && !db_Accounts.UserCanEditOrgIDX(UserIDX, selAgency.ConvertOrDefault <Guid>()))
            {
                TempData["Error"] = "You cannot edit this agency.";
                return(RedirectToAction("AccessDenied", "Home"));
            }


            var model = new vmDashboardAgency();

            model.agency = db_Ref.GetT_OE_ORGANIZATION_ByID(selAgency.ConvertOrDefault <Guid>());
            model.users  = db_Accounts.GetT_OE_USERSByAgency(selAgency.ConvertOrDefault <Guid>());
            //database
            model.SelectedDatabase = db_Ref.GetT_OE_ORGANIZATION_TAGS_ByOrgAttribute(selAgency.ConvertOrDefault <Guid>(), "Database");
            model.AllDatabase      = db_Ref.GetT_OE_ORGANIZATION_TAGS_ByAttributeAll(selAgency.ConvertOrDefault <Guid>(), "Database").Select(x => new SelectListItem {
                Value = x, Text = x
            });
            //app framework
            model.SelectedAppFramework = db_Ref.GetT_OE_ORGANIZATION_TAGS_ByOrgAttribute(selAgency.ConvertOrDefault <Guid>(), "App Framework");
            model.AllAppFramework      = db_Ref.GetT_OE_ORGANIZATION_TAGS_ByAttributeAll(selAgency.ConvertOrDefault <Guid>(), "App Framework").Select(x => new SelectListItem {
                Value = x, Text = x
            });
            //ent services
            model.org_ent_services = db_EECIP.GetT_OE_ORGANIZATION_ENTERPRISE_PLATFORM(selAgency.ConvertOrDefault <Guid>());

            return(View(model));
        }
        // GET: /Dashboard/ProjectCard/1
        public ActionResult ProjectCard(string strid)
        {
            int UserIDX = db_Accounts.GetUserIDX();

            Guid id;

            if (Guid.TryParse(strid, out id))
            {
                var model = new vmDashboardProjectCard();
                model.project = db_EECIP.GetT_OE_PROJECTS_ByIDX(id);
                if (model.project != null)
                {
                    T_OE_ORGANIZATION _org = db_Ref.GetT_OE_ORGANIZATION_ByID(model.project.ORG_IDX.ConvertOrDefault <Guid>());
                    if (_org != null)
                    {
                        model.OrgName = _org.ORG_NAME;
                    }

                    model.SelectedProgramAreas = db_EECIP.GetT_OE_PROJECT_TAGS_ByAttributeSelected(model.project.PROJECT_IDX, "Program Area");
                    model.SelectedFeatures     = db_EECIP.GetT_OE_PROJECT_TAGS_ByAttributeSelected(model.project.PROJECT_IDX, "Project Feature");
                    model.sProjectUrlList      = db_EECIP.GetT_OE_PROJECTS_URL_ByProjIDX(model.project.PROJECT_IDX);
                    T_OE_USERS u = db_Accounts.GetT_OE_USERSByIDX(model.project.MODIFY_USERIDX ?? model.project.CREATE_USERIDX ?? -1);
                    if (u != null)
                    {
                        model.LastUpdatedUser = u.FNAME + " " + u.LNAME;
                    }
                    model.ProjectVotePoints          = db_EECIP.GetT_OE_PROJECT_VOTES_TotalByProject(model.project.PROJECT_IDX);
                    model.HasVoted                   = db_EECIP.GetT_OE_PROJECT_VOTES_HasVoted(model.project.PROJECT_IDX, UserIDX);
                    model.UserBelongsToProjectAgency = db_Accounts.UserCanEditOrgIDX(db_Accounts.GetUserIDX(), model.project.ORG_IDX.ConvertOrDefault <Guid>());
                    //project contact
                    if (model.project.PROJECT_CONTACT_IDX != null)
                    {
                        model.ProjectContact = db_Accounts.GetT_OE_USERSByIDX(model.project.PROJECT_CONTACT_IDX ?? -1);
                    }
                    model.files_existing = db_EECIP.GetT_OE_DOCUMENTS_ByProjectID(model.project.PROJECT_IDX);
                }

                if (model.project != null)
                {
                    return(View(model));
                }
            }

            TempData["Error"] = "No project found";
            return(RedirectToAction("Index", "Dashboard"));
        }
Exemple #27
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //*************** VALIDATION ********************************
            if (txtPwd.Text != txtPwd2.Text)
            {
                lblMsg.Text = "Passwords do not match";
                return;
            }
            //*************** END VALIDATION ********************************

            string oauthcrd = Request.QueryString["oauthcrd"];

            //decrypt oauth string
            string oauthDecode = System.Web.HttpUtility.UrlDecode(oauthcrd);

            oauthDecode = oauthDecode.Replace(" ", "+");   //fix situations where spaces and plus get mixed up
            string decryptStr = new SimpleAES().Decrypt(oauthDecode);

            //split into password and username
            string[] s = System.Text.RegularExpressions.Regex.Split(decryptStr, "\\|\\|");

            CustMembershipProvider c = new CustMembershipProvider();

            if (c.ValidateUser(s[1], s[0]) == true)
            {
                if (c.ChangePassword(s[1], s[0], txtPwd.Text))
                {
                    if (Membership.ValidateUser(s[1], txtPwd.Text))
                    {
                        FormsAuthentication.SetAuthCookie(s[1], false);
                        FormsAuthentication.RedirectFromLoginPage(s[1], false);
                        string ddd = User.Identity.Name;

                        T_OE_USERS u = db_Accounts.GetT_OE_USERSByID(s[1]);
                        if (u != null)
                        {
                            db_Accounts.UpdateT_OE_USERS(u.USER_IDX, null, null, null, null, null, null, null, null, System.DateTime.Now, null, null, "system");
                            //set important session variables
                            Session["UserIDX"] = u.USER_IDX;

                            Response.Redirect("~/App_Pages/Secure/Dashboard.aspx");
                        }
                    }
                }
            }
        }
Exemple #28
0
        public ActionResult LeaderboardDtl(int?id)
        {
            var model = new vmDashboardLeaderboardDtl
            {
                UserPointDetails = db_Forum.GetMembershipUserPoints_ByUserID(id ?? 0)
            };

            T_OE_USERS u = db_Accounts.GetT_OE_USERSByIDX(id ?? 0);

            if (u != null)
            {
                model.UserName = u.FNAME + " " + u.LNAME;
            }


            return(View(model));
        }
Exemple #29
0
 public static int DeleteT_OE_USERS(int idx)
 {
     using (OpenEnvironmentEntities ctx = new OpenEnvironmentEntities())
     {
         try
         {
             T_OE_USERS row = new T_OE_USERS();
             row = (from c in ctx.T_OE_USERS where c.USER_IDX == idx select c).First();
             ctx.DeleteObject(row);
             ctx.SaveChanges();
             return(1);
         }
         catch (Exception ex)
         {
             return(0);
         }
     }
 }
        public override string ResetPassword(string username, string answer)
        {
            using (OpenEnvironmentEntities context = new OpenEnvironmentEntities())
            {
                T_OE_USERS u = db_Accounts.GetT_OE_USERSByID(username);
                if (u != null)
                {
                    //generate new password
                    string newPass = RandomString(8);
                    string salt    = GenerateSalt();

                    string hashpass = HashPassword(newPass, _PasswordFormat, salt);
                    //save updated information
                    if (db_Accounts.UpdateT_OE_USERS(u.USER_IDX, hashpass, salt, null, null, null, null, true, null, null, null, null, "system") > 0)
                    {
                        //send email
                        string msg = "Your password has been reset. Your new temporary password is: " + "\r\n\r\n";
                        msg += newPass + "\r\n\r\n";
                        msg += "When you login for the first time you will be asked to set a permanent password.";
                        if (u.EMAIL == null)
                        {
                            return("User does not have email address.");
                        }
                        if (Utils.SendEmail(null, u.EMAIL.Split(';').ToList(), null, null, "Open Waters Password Reset", msg, null))
                        {
                            return("Email has been sent.");
                        }
                        else
                        {
                            return("Error in sending email");
                        }
                    }
                    else
                    {
                        return("Error updating password");
                    }
                }
                else
                {
                    return("Email does not exist in the system.");
                }
            }
        }