コード例 #1
0
        protected void btnAccountRecovery_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtAccountRecovery.Text.Trim()))
            {
                ClsAuthentication         clsUserRegistration = new ClsAuthentication();
                CPT_EmailTemplate         registrationEmail   = new CPT_EmailTemplate();
                List <CPT_ResourceMaster> lstuserDetails      = new List <CPT_ResourceMaster>();
                lstuserDetails = clsUserRegistration.getDetailsforPasswordRecovery(txtAccountRecovery.Text.Trim());
                if (lstuserDetails.Count > 0)
                {
                    try
                    {
                        registrationEmail.Name = "ForgetPassword";
                        registrationEmail.To   = new List <string>();
                        registrationEmail.To.Add(txtAccountRecovery.Text);
                        registrationEmail.ToUserName = new List <string>();
                        registrationEmail.ToUserName.Add(lstuserDetails[0].EmployeetName);
                        registrationEmail.UID = lstuserDetails[0].EmployeeMasterID.ToString();
                        TokenMessageTemplate valEmail = new TokenMessageTemplate();
                        valEmail.SendEmail(registrationEmail);
                        //btnAccountRecovery.Visible = false;
                        lblMessage.Visible      = true;
                        txtAccountRecovery.Text = string.Empty;
                        lblMessage.ForeColor    = System.Drawing.Color.Green;
                        lblMessage.Text         = "<strong  class='text - center'>If you have registered previously we have sent you a verification email, for password resetting click on that link. If you do not see it in your inbox please note that your email provider may have mistaken us as spam. If no email has arrived please try again.</strong>";
                        Response.AppendHeader("Refresh", "10;url=Login.aspx");
                        //Response.Redirect("Login.aspx");
                    }

                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
                else
                {
                    lblMessage.ForeColor = System.Drawing.Color.Red;
                    lblMessage.Visible   = true;
                    lblMessage.Text      = "   Email not found...";
                }
            }
        }
コード例 #2
0
        protected void loginButton_Click(object sender, EventArgs e)
        {
            CPT_ResourceMaster auth             = new CPT_ResourceMaster();
            ClsAuthentication  blauthentication = new ClsAuthentication();

            auth.Email            = txtEmail.Text.Trim();
            auth.EmployeePassword = txtPassword.Text.Trim();
            List <CPT_ResourceMaster> lstuserdetails = new List <CPT_ResourceMaster>();

            if (chkRemember.Checked)
            {
                Response.Cookies["UserName"].Value   = txtEmail.Text.Trim();
                Response.Cookies["Password"].Value   = txtPassword.Text.Trim();
                Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(30);
                Response.Cookies["Password"].Expires = DateTime.Now.AddDays(30);
            }
            else
            {
                Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(-1);
                Response.Cookies["Password"].Expires = DateTime.Now.AddDays(-1);
            }

            lstuserdetails = blauthentication.getActiveUser(auth);
            if (lstuserdetails.Count > 0)
            {
                Session["UserDetails"] = lstuserdetails;
                Response.Redirect("Dashboard.aspx");
            }

            else
            {
                lblErrorMsg.Visible   = true;
                lblErrorMsg.ForeColor = System.Drawing.Color.Red;
                lblErrorMsg.Text      = "Your email or password is incorrect!";
            }
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //int res = 1;
            try
            {
                if (Session["UserDetails"] != null)
                {
                    List <CPT_ResourceMaster> lstdetils = new List <CPT_ResourceMaster>();
                    lstdetils = (List <CPT_ResourceMaster>)Session["UserDetails"];

                    lblUserName.Text = lstdetils[0].EmployeetName;
                    ClsAuthentication authmenu = new ClsAuthentication();
                    rptMeanu.DataSource = authmenu.getMeanu(lstdetils[0].RolesID);
                    rptMeanu.DataBind();
                    string CURL = System.Web.HttpContext.Current.Request.Url.AbsoluteUri;



                    //if (CURL.ToLower().Trim().Contains("dashboard"))

                    //{



                    //}

                    //else

                    //{

                    //    ClsAuthentication valid = new ClsAuthentication();

                    //    //res = valid.EmpAccess();

                    //}

                    //if (res == 0)

                    //{

                    //    Response.Redirect("ErrorPages/AuthenticationFailed.aspx");

                    //}
                }
                else
                {
                    Response.Redirect("login.aspx");
                }


                /* Prevent direct URL Access  */
                string referer = Request.ServerVariables["HTTP_REFERER"];
                if (string.IsNullOrEmpty(referer))
                {
                    Session["UserId"] = null;
                    Response.Redirect("ErrorPages/AuthenticationFailed.aspx");
                }

                /* Prevent direct URL Access ends  */
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }