コード例 #1
0
    public static string ATHENTICATE_FOR_RECORD(string UserPass)
    {
        int?userId;

        try
        {
            CRBusinessLogicLayer.IsValidUser(HttpContext.Current.Request.Cookies["UserName"].Value, UserPass, out userId);
            return(userId.ToString());
        }
        catch (Exception)
        {
            // ignored
        }
        return(null);
    }
コード例 #2
0
ファイル: Default.aspx.cs プロジェクト: ashok-palla/Farmer
 public static string UserChangePassword(string OldPassword, string NewPassword)
 {
     try
     {
         int?userId;
         CRBusinessLogicLayer.IsValidUser(HttpContext.Current.Request.Cookies["UserName"].Value, OldPassword, out userId);
         if (userId == null)
         {
             return("Incorrect Old Password");
         }
         else
         {
             CRBusinessLogicLayer.UpdatePassword(HttpContext.Current.Request.Cookies["UserName"].Value, NewPassword);
             return("Successfully Saved New Password");
         }
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
コード例 #3
0
ファイル: Farmer.aspx.cs プロジェクト: ashok-palla/Farmer
 public static string UserChangePassword(string OldPassword, string NewPassword)
 {
     try
     {
         int?userId;
         CRBusinessLogicLayer.IsValidUser(HttpContext.Current.Session["UserName"].ToString(), OldPassword, out userId);
         if (userId == null)
         {
             return("Incorrect Old Password");
         }
         else
         {
             CRBusinessLogicLayer.UpdatePassword(HttpContext.Current.Session["UserName"].ToString(), NewPassword);
             return("Successfully Saved New Password");
         }
     }
     catch (Exception ex)
     {
         logfile.ErrorFormat(ex.Message);
         return(ex.Message);
     }
 }
コード例 #4
0
    protected void ButLogin_Click(object sender, EventArgs e)
    {
        try
        {
            int?   userId;
            string connectionString            = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["CustomerRecoveryConnectionString"].ConnectionString;
            SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectionString);
            string name = builder.InitialCatalog;
            CRBusinessLogicLayer.IsValidUser(txtUserName.Text, txtPassword.Text, out userId);
            if (userId == null)
            {
                txtUserName.Text = "";
                txtPassword.Text = "";
                LbError.Text     = "Invalid  User Name/Password.";
                LbError.Visible  = true;
            }
            else
            {
                var    ds                        = CRBusinessLogicLayer.GetSequerityQuestion((int)userId);
                string SessionuserID             = name + "_" + "userid";
                var    UserType                  = ds.Tables[0].Rows[0]["UserRole"].ToString();
                var    CityID                    = ds.Tables[0].Rows[0]["City"].ToString();
                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, txtUserName.Text, DateTime.Now, DateTime.Now.AddDays(7), true, String.Format("{0}|{1}|{2}", txtUserName.Text, userId, UserType));
                string hash                      = FormsAuthentication.Encrypt(ticket);
                FormsAuthentication.SetAuthCookie(txtUserName.Text, true);
                Response.AppendCookie(new HttpCookie(SessionuserID, userId.ToString()));
                Response.AppendCookie(new HttpCookie("UserName", txtUserName.Text));
                Response.AppendCookie(new HttpCookie("UserRole", UserType));
                System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
                Byte[] bytes = encoding.GetBytes(txtPassword.Text);
                string pwd   = CRBusinessLogicLayer.PassEncrypt(bytes);
                Response.AppendCookie(new HttpCookie("Pass", pwd));
                Response.AppendCookie(new HttpCookie("CityID", CityID));
                Response.AppendCookie(new HttpCookie("USERID", userId.ToString()));
                Response.AppendCookie(new HttpCookie("udata", hash));

                string url = string.Empty;
                ds = CRBusinessLogicLayer.GetUserAccessURL((int)userId);
                if (ds.Tables[0].Rows.Count == 1)
                {
                    url = ds.Tables[0].Rows[0]["ScreenURL"].ToString();
                }
                else if (url == string.Empty)
                {
                    Response.Redirect(
                        Convert.ToInt16(UserType) == 2
                            ? "~/DailyTransactions/NPADetails.aspx"
                            : "~/Masters/Farmer.aspx", false);
                }
                if (url != string.Empty)
                {
                    Response.Redirect(url, false);
                }
            }
        }
        catch (Exception ex)
        {
            LbError.Text    = ex.Message;
            LbError.Visible = true;
        }
    }