Example #1
0
    static LoggedProfile LoggedCookieRead()
    {
        LoggedProfile lu = null;
        HttpCookie    ck = System.Web.HttpContext.Current.Request.Cookies[LoggedCookieName()];

        if (ck != null)
        {
            try
            {
                string       strContent = ut.Base64Decode(ck.Value);
                CQueryString qs         = new CQueryString(strContent);
                string       email      = qs["e"];
                string       password   = qs["p"];
                if (!String.IsNullOrWhiteSpace(email) && !String.IsNullOrWhiteSpace(password))
                {// load from db
                    lu = LoggedDbRead(email, password);
                }
            }
            catch (Exception ex)
            {
                Log.AddLogEntry(ex.ToString());
            };
        }
        return(lu);
    }
Example #2
0
    static void LoggedCookieWrite(LoggedProfile lu)
    {
        HttpCookie ck = new HttpCookie(LoggedCookieName());

        ck.Value    = ut.Base64Encode("e=" + lu.Email + "&p=" + lu.Password);
        ck.Expires  = System.DateTime.Now.AddDays(14);
        ck.Secure   = true;
        ck.HttpOnly = true;
        System.Web.HttpContext.Current.Response.Cookies.Add(ck);
    }
Example #3
0
    public static LoggedProfile LoggedDbRead(string email, string password)
    {
        LoggedProfile lu = null;
        DataTable     dt = new DataTable();
        int           r  = new Jobs().Job_Login(email, password, ref dt);

        if (dt.Rows.Count > 0)
        {
            lu = LoggedProfileBuild(dt);
        }
        else
        {
            lu = new LoggedProfile();
        }
        return(lu);
    }
Example #4
0
    public static LoggedProfile LoggedProfileBuild(DataTable dt)
    {
        LoggedProfile lu = null;

        if (dt.Rows.Count < 1)
        {
            return(lu);
        }

        lu = new LoggedProfile(dt.Rows[0]["email"].ToString(),
                               dt.Rows[0]["pass"].ToString(),
                               ut.Str2Int(dt.Rows[0]["id"].ToString()),
                               dt.Rows[0]);
        System.Web.HttpContext.Current.Session[LoggedCookieName()] = lu;
        LoggedCookieWrite(lu);
        return(lu);
    }
Example #5
0
 public async Task <ActionResult> Login(Models.JobLogin jl)
 {
     if (ModelState.IsValid)
     {
         LoggedProfile lp = LoggedProfile.LoggedDbRead(jl.JobEmail, jl.Password);
         if (lp.Id > 0)
         {
             ViewBag.msg = 1;
             return(PartialView("Login", jl));
         }
         else
         {
             ViewBag.msg = -2;
             return(PartialView("Login", jl));
         }
     }
     else
     {
         ViewBag.msg = -1;
         return(PartialView("Login", jl));
     }
 }
Example #6
0
 public ActionResult Logout()
 {
     LoggedProfile.LoggedDestroy();
     return(RedirectToAction("Index", "Order"));
 }