예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                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]) == false)
                {
                    lblMsg.Text = "Verification failed";
                    pnl1.Visible = false;
                }
                else
                    pnl1.Visible = true;
            }
            catch
            {
                lblMsg.Text = "Verification failed";
                pnl1.Visible = false;
            }
        }
예제 #2
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");

                        }

                    }

                }
            }
        }
예제 #3
0
        public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            status = MembershipCreateStatus.Success;

            //******************************** BEGIN VALIDATION ********************************************************
            //Validate Username Length
            if (!Utils.ValidateParameter(ref username, true, true, true, 25))
            {
                status = MembershipCreateStatus.InvalidUserName;
                return null;
            }

            T_OE_USERS u = db_Accounts.GetT_OE_USERSByID(username);
            if (u != null)
            {
                //Duplicate username found -return error
                status = MembershipCreateStatus.DuplicateUserName;
                return null;
            }

            if (Utils.IsEmail(email) == false)
            {
                status = MembershipCreateStatus.InvalidEmail;
                return null;
            }
            //******************************** END VALIDATION ***********************************************************

            try
            {
                //Generate password and hash it
                password = RandomString(10);
                string salt = GenerateSalt();
                string hashpass = HashPassword(password, MembershipPasswordFormat.Hashed, salt);

                //create user record
                int createUser = db_Accounts.CreateT_OE_USERS(username, hashpass, salt, "", "", email, true, true, null, null, null, "system");
                if (createUser > 0)  //Success
                {
                    //Add user to PUBLIC Role
                    db_Accounts.CreateT_VCCB_USER_ROLE(3, createUser, "system");

                    //encrypt username for email
                    string encryptOauth = new SimpleAES().Encrypt(password + "||" + username);
                    encryptOauth = System.Web.HttpUtility.UrlEncode(encryptOauth);

                    //send verification email to user
                    string message = "Welcome to Tribal-FERST Mvskoke Open Waters Module. Tribal-FERST Mvskoke Open Waters Module allows you to manage your water quality data and synchronize it with EPA-WQX.  "
                        + "\r\n\r\n Your username is: " + username
                        + "\r\n\r\n You must activate your account by clicking the following link: "
                        + "\r\n\r\n " + db_Ref.GetT_OE_APP_SETTING("Public App Path") + "Account/Verify.aspx?oauthcrd=" + encryptOauth
                        + "\r\n\r\n After verifying your account you will be prompted to enter a permanent password.";

                    bool EmailStatus = Utils.SendEmail(null, email.Split(';').ToList(), null, null, "Confirm Your Tribal-FERST Mvskoke Open Waters Module", message, null);
                    if (EmailStatus == false)
                    {
                        status = MembershipCreateStatus.InvalidEmail;
                        db_Accounts.DeleteT_OE_USERS(createUser);
                    }

                    return new MembershipUser("CustMembershipProvider", username, createUser, email, passwordQuestion, null, isApproved, false, System.DateTime.Now, System.DateTime.Now, System.DateTime.Now, System.DateTime.Now, System.DateTime.Now);
                }
                else
                {
                    status = MembershipCreateStatus.ProviderError;
                    return null;
                }

            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
예제 #4
0
        public static int InsertOrUpdateT_WQX_ORGANIZATION(string oRG_ID, string oRG_NAME, string oRG_DESC, string tRIBAL_CODE, string eLECTRONIC_ADDRESS, 
            string eLECTRONICADDRESSTYPE, string tELEPHONE_NUM, string tELEPHONE_NUM_TYPE, string TELEPHONE_EXT, string cDX_SUBMITTER_ID,
            string cDX_SUBMITTER_PWD, bool? cDX_SUBMIT_IND, string dEFAULT_TIMEZONE, string cREATE_USER = "******", string mAIL_ADDRESS = null,
            string mAIL_ADD_CITY = null, string mAIL_ADD_STATE = null, string mAIL_ADD_ZIP = null)
        {
            using (OpenEnvironmentEntities ctx = new OpenEnvironmentEntities())
            {
                Boolean insInd = false;
                try
                {
                    T_WQX_ORGANIZATION a = new T_WQX_ORGANIZATION();

                    if (oRG_ID != null)
                        a = (from c in ctx.T_WQX_ORGANIZATION
                             where c.ORG_ID == oRG_ID
                             select c).FirstOrDefault();

                    if (a == null) //insert case
                    {
                        a = new T_WQX_ORGANIZATION();
                        insInd = true;
                        a.ORG_ID = oRG_ID;
                    }

                    if (oRG_NAME != null) a.ORG_FORMAL_NAME = oRG_NAME;
                    if (oRG_DESC != null) a.ORG_DESC = oRG_DESC;
                    if (tRIBAL_CODE != null) a.TRIBAL_CODE = tRIBAL_CODE;
                    if (eLECTRONIC_ADDRESS != null) a.ELECTRONICADDRESS = eLECTRONIC_ADDRESS;
                    if (eLECTRONICADDRESSTYPE != null) a.ELECTRONICADDRESSTYPE = eLECTRONICADDRESSTYPE;
                    if (tELEPHONE_NUM != null) a.TELEPHONE_NUM = tELEPHONE_NUM;
                    if (tELEPHONE_NUM_TYPE != null) a.TELEPHONE_NUM_TYPE = tELEPHONE_NUM_TYPE;
                    if (TELEPHONE_EXT != null) a.TELEPHONE_EXT = TELEPHONE_EXT;
                    if (dEFAULT_TIMEZONE != null) a.DEFAULT_TIMEZONE = dEFAULT_TIMEZONE;
                    if (cDX_SUBMITTER_ID != null) a.CDX_SUBMITTER_ID = cDX_SUBMITTER_ID;
                    if (cDX_SUBMIT_IND != null) a.CDX_SUBMIT_IND = cDX_SUBMIT_IND;
                    if (cDX_SUBMITTER_PWD != null && cDX_SUBMITTER_PWD != "--------")
                    {
                        //encrypt CDX submitter password for increased security
                        string encryptOauth = new SimpleAES().Encrypt(cDX_SUBMITTER_PWD);
                        encryptOauth = System.Web.HttpUtility.UrlEncode(encryptOauth);
                        a.CDX_SUBMITTER_PWD_HASH = encryptOauth;
                    }
                    if (dEFAULT_TIMEZONE != null) a.DEFAULT_TIMEZONE = dEFAULT_TIMEZONE;
                    if (mAIL_ADDRESS != null) a.MAILING_ADDRESS = mAIL_ADDRESS;
                    if (mAIL_ADD_CITY != null) a.MAILING_ADD_CITY = mAIL_ADD_CITY;
                    if (mAIL_ADD_STATE != null) a.MAILING_ADD_STATE = mAIL_ADD_STATE;
                    if (mAIL_ADD_ZIP != null) a.MAILING_ADD_ZIP = mAIL_ADD_ZIP;

                    if (insInd) //insert case
                    {
                        a.CREATE_USERID = cREATE_USER.ToUpper();
                        a.CREATE_DT = System.DateTime.Now;
                        ctx.AddToT_WQX_ORGANIZATION(a);
                    }
                    else
                    {
                        a.UPDATE_USERID = cREATE_USER.ToUpper();
                        a.UPDATE_DT = System.DateTime.Now;
                    }

                    ctx.SaveChanges();

                    return 1;
                }
                catch (Exception ex)
                {
                    return 0;
                }
            }
        }