Example #1
0
        public ActionResult LogIn(string uname, string pwd)

        {
            pwd = pwd.Replace("\"", string.Empty);
            bool   logincheck = false;
            string DecryptKey = Convert.ToString(ConfigurationManager.AppSettings["DecryptKey"]);

            pwd = MvcHelper.CodeDecrypt(pwd.Trim(), DecryptKey.Trim());
            string ErrorMsg = string.Empty; string Action = string.Empty; string cntrlr = string.Empty, groupname = string.Empty, pages = string.Empty;

            tbl_UserDetail      user  = new tbl_UserDetail();
            UserTransactionData utobj = new UserTransactionData();
            ADManager           AdObj = new ADManager();

            logincheck = AdObj.ChcekLogin(uname, pwd, ref groupname);

            //user = MvcHelper.GetUser(uname, pwd, ref pages);
            //if (user != null)
            //{
            //    logincheck = true;
            //    groupname = user.UserGroup;
            //}
            if (logincheck)
            {
                if (!string.IsNullOrEmpty(groupname))
                {
                    user = new tbl_UserDetail()
                    {
                        AccountName = uname,
                        UserGroup   = groupname,
                    };
                    user.GroupPages = MvcHelper.GetGroupPages(groupname);
                    //int check = utobj.CheckMachineAvailable(System.Net.Dns.GetHostEntry(Request.UserHostAddress).HostName);
                    //if (check == 1)
                    //{
                    //Session["Machine"] = System.Net.Dns.GetHostEntry(Request.UserHostAddress).HostName;
                    MvcHelper.SaveUser(user);
                    Action = "index"; cntrlr = "Dashboard";
                    // }
                    //else
                    //{
                    //    ErrorMsg = "Sorry...!!! Multiple user login is not allowed.";
                    //}
                }
                else
                {
                    ErrorMsg = "User type is not authorized for the dashboard...!";
                }
            }
            else
            {
                ErrorMsg = "Wrong credential...!";
            }
            if (!string.IsNullOrEmpty(ErrorMsg))
            {
                TempData["invalidmsg"] = ErrorMsg;
                return(RedirectToAction("LogIn"));
            }
            else
            {
                Session["User"] = user;
                return(RedirectToAction(Action, cntrlr));
            }
        }