Ejemplo n.º 1
0
        public ActionResult Login(TccgLogin login)
        {
            var    dbcontext = new TCCGDataContext();
            var    security  = new clssecurity();
            bool   logres;
            bool   loginstatus = true;
            string strerrormsg = string.Empty;

            if (string.IsNullOrEmpty(login.uname) || string.IsNullOrEmpty(login.upass))
            {
                @ViewBag.Title = "Admin | Login";
                return(View());
            }


            logres = dbcontext.IsLogin(login.uname.ToUpper(), security.psEncrypt(login.upass)) == true ? true : false;


            if (logres)
            {
                TCCG_USER up = dbcontext.TCCG_USERs.First(aa => aa.username == login.uname);

                if (up.userstatus != true)
                {
                    strerrormsg += "Sorry your account is inactive!";
                    loginstatus  = false;
                }


                if (!loginstatus)
                {
                    ViewBag.error  = strerrormsg;
                    @ViewBag.Title = "TCCG | Login";
                }
                else
                {
                    Session["_cid"]  = up.username;
                    Session["_crol"] = up.usergroup;
                    Session.Timeout  = 30;
                }
            }


            if (!loginstatus)
            {
                return(View());
            }
            else
            {
                this.SetPmsCookie(login.RememberMe, login.uname.ToUpper(), login.upass);

                return(RedirectToAction("Index"));
            }
        }
Ejemplo n.º 2
0
        public void SetPmsCookie(bool isremember, string username, string password)
        {
            clssecurity sec = new clssecurity();

            if (isremember)
            {
                HttpCookie cookie = Request.Cookies["tccg"];
                if (cookie == null)
                {
                    cookie           = new HttpCookie("tccg");
                    cookie["_00un"]  = username;
                    cookie["_00up"]  = sec.psEncrypt(password);
                    cookie["_00rmd"] = isremember.ToString();
                    Response.Cookies.Add(cookie);
                }
            }
        }
Ejemplo n.º 3
0
        public JsonResult login(TccgLogin login)
        {
            try
            {
                string msg      = string.Empty;
                var    security = new clssecurity();
                bool?  logres;
                bool   isresult = false;
                logres = dbcontext.IsLogin(login.uname, security.psEncrypt(login.upass));


                if (logres == true)
                {
                    TCCG_USER up = dbcontext.TCCG_USERs.First(aa => aa.username == login.uname);

                    if (up.userstatus != true)
                    {
                        msg = "Your account is not active, Please contact Administrator";
                    }
                    else
                    {
                        Session["_cid"]  = up.username;
                        Session["_crol"] = up.usergroup;
                        Session.Timeout  = 30;
                        this.SetPmsCookie(login.RememberMe, login.uname, login.upass);
                        isresult = true;
                    }
                }
                else
                {
                    msg = "Please Contact Administrator!";
                }

                return(Json(new { result = true, msg = msg, isresult = isresult }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { result = false, err = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 4
0
        public JsonResult CreateNewUser(UserSetup details)
        {
            try
            {
                clssecurity security = new clssecurity();

                string newpass    = security.psEncrypt(details.password);
                string str_result = string.Empty;
                if (dbcontext.SPROC_SAVE_USER(details.uname, newpass, details.fullname, details.designation,
                                              details.email, "SID002", true, DateTime.Now.Date, DateTime.Now.Date).ReturnValue.ToString() == "0")
                {
                    List <TCCG_USER_RIGHT> q_listdel = (from aa in dbcontext.TCCG_USER_RIGHTs
                                                        where aa.Username == details.uname
                                                        select aa).ToList();
                    if (q_listdel.Count != 0)
                    {
                        dbcontext.TCCG_USER_RIGHTs.DeleteAllOnSubmit(q_listdel);
                        dbcontext.SubmitChanges();
                    }

                    foreach (var row in details.accesslst)
                    {
                        if (row.ischeck)
                        {
                            str_result = dbcontext.SPROC_SAVE_USER_RIGHTS(row.menuid, details.uname, procedure.GetUsername()).ReturnValue.ToString();
                        }
                    }
                }

                return(Json(new { result = true }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { result = false, err = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }