예제 #1
0
        public ActionResult UnLock(LoginModel loginModel, string ReturnUrl)
        {
            if (ModelState.IsValid)
            {
                if (loginModel != null || !string.IsNullOrWhiteSpace(loginModel.EmailId) || !string.IsNullOrWhiteSpace(loginModel.Password))
                {
                    loginModel.Result = (!string.IsNullOrWhiteSpace(loginModel.EmailId) && !string.IsNullOrWhiteSpace(loginModel.Password))
                                        ? _repository.Login(loginModel.EmailId, loginModel.Password, loginModel.Persist)
                                        : UserAuthenticationResult.UnknownUsernameOrPassword;

                    loginModel.LoginAttempt = true;

                    if (loginModel.Result == UserAuthenticationResult.Authenticated)
                    {
                        User currentUser = _repository.GetUserByEmailId(loginModel.EmailId);
                        if (currentUser != null)
                        {
                            loginModel.Password = currentUser.Password;
                            loginModel.EmailId = currentUser.EmailAddress;
                            FormsAuthentication.SetAuthCookie(currentUser.Row_Id.ToString(), loginModel.Persist);
                        }

                        HttpContext.Cache["currentloggedinuser"] = new User();
                        HttpContext.Cache.Insert("currentloggedinuser", currentUser);

                        //if (currentUser != null && currentUser.UserType == 1)
                        //{
                        //    return RedirectToAction("Index", "Home");
                        //}
                        //else if (currentUser != null && currentUser.UserType == 2)
                        //{
                        //    return RedirectToAction("Index", "Staff");
                        //}
                        //else if (currentUser != null && currentUser.UserType == 6)
                        //{
                        //    return RedirectToAction("Index", "Home");
                        //}
                        //else
                        //{
                        //    return RedirectToAction("Index", "Client");
                        //}

                        if (currentUser != null)
                        {
                            switch (currentUser.UserType)
                            {
                                case 1:
                                    return RedirectToAction("Index", "Home");
                                case 2:
                                   // return RedirectToAction("Index", "Staff");
                                    return RedirectToAction("Index", "Home");
                                case 4:
                                    return RedirectToAction("Index", "Home");
                                case 6:
                                    return RedirectToAction("Index", "Home");
                                default:
                                    //return RedirectToAction("Index", "Client");
                                    return RedirectToAction("Index", "JobTracking");
                            }
                        }
                    }
                }
            }
            return View("UnLock", loginModel);
        }
예제 #2
0
        public ActionResult Login(LoginModel loginModel, string ReturnUrl)
        {
            ClearCache();

            if (ModelState.IsValid)
                if (loginModel != null || !string.IsNullOrWhiteSpace(loginModel.EmailId) || !string.IsNullOrWhiteSpace(loginModel.Password))
                {
                    loginModel.Result = (!string.IsNullOrWhiteSpace(loginModel.EmailId) && !string.IsNullOrWhiteSpace(loginModel.Password))
                                        ? _repository.Login(loginModel.EmailId, loginModel.Password, loginModel.Persist)
                                        : UserAuthenticationResult.UnknownUsernameOrPassword;

                    loginModel.LoginAttempt = true;

                    string DomainName = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host + (Request.Url.IsDefaultPort ? "" : ":" + Request.Url.Port);
                    var CompanylogoInfo = _repository.GetCompanyLogo(DomainName);

                    if (CompanylogoInfo.Count > 0)
                    {
                        foreach (var item in CompanylogoInfo)
                        {
                            loginModel.OrgId = item.OrgId;
                            loginModel.OrgName = item.OrgName;
                            loginModel.Logolocation = item.Logolocation;
                            loginModel.Subdomain = DomainName;
                        }
                    }
                    else
                    {
                        loginModel.OrgId = 0;
                        loginModel.OrgName = string.Empty;
                        if (System.Configuration.ConfigurationManager.AppSettings["DefaultcompanyLogo"] != null)
                        {
                            loginModel.Logolocation = System.Configuration.ConfigurationManager.AppSettings["DefaultcompanyLogo"].ToString();
                        }
                        else
                        {
                            loginModel.Logolocation = string.Empty;
                        }

                        loginModel.Subdomain = DomainName;

                        loginModel.Logolocation = "~/Images/DPIlogo.jpg";//item.Logolocation;

                    }

                    if (loginModel.Result == UserAuthenticationResult.Authenticated)
                    {
                        User currentUser = _repository.GetUserByEmailId(loginModel.EmailId);
                        if (currentUser != null)
                        {
                            loginModel.Password = currentUser.Password;
                            loginModel.EmailId = currentUser.EmailAddress;
                            FormsAuthentication.SetAuthCookie(currentUser.Row_Id.ToString(), loginModel.Persist);
                        }

                        HttpContext.Cache["currentloggedinuser"] = new User();
                        HttpContext.Cache.Insert("currentloggedinuser", currentUser);

                        //  if (currentUser != null && currentUser.UserType == 1 || currentUser.UserType == 3)
                        if (currentUser != null)
                        {
                            return RedirectToAction("Index", "Home");
                            // return RedirectToAction("Index", "Scheduler");
                        }
                        else if (currentUser != null && currentUser.UserType == 2)
                        {
                            return RedirectToAction("Index", "JobTracking");
                        }
                        else
                        {
                            ViewBag.NotAuthorizedUser = "******";
                        }
                        //else if (currentUser != null && currentUser.UserType == 2)
                        //{
                        //    return RedirectToAction("Index", "Staff");
                        //}
                        //else
                        //{
                        //    return RedirectToAction("Index", "Client");
                        //}
                    }
                }
            return View("Login", loginModel);
        }
예제 #3
0
        public ActionResult UnLock(string ReturnUrl)
        {
            var currentUser = OrderManagement.Web.Helper.Utilitties.UserManager.Current();

            LoginModel loginModel = new LoginModel();
            loginModel.EmailId = currentUser.EmailAddress;
            return View(loginModel);
        }
예제 #4
0
        public ActionResult Login(string ReturnUrl)
        {
            var loginmodels = new LoginModel();
            var loginmodeladasdasd = new LoginModel();
            var loginmodel = new LoginModel();

            string DomainName = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host + (Request.Url.IsDefaultPort ? "" : ":" + Request.Url.Port);

            // string DomainName = Request.Url.Scheme + "--" + System.Uri.SchemeDelimiter + "--" + Request.Url.Host + "--" + (Request.Url.IsDefaultPort ? "" : ":" + Request.Url.Port);

            Uri myUri = new Uri(DomainName, UriKind.Absolute);
            string subdomainName = GetSubDomain(myUri);

            // string DomainName = Request.Url.Host;

            loginmodel.Logolocation = "~/Images/DPIlogo.jpg";//item.Logolocation;
            //need to uncomment for dynamic logo

            var CompanylogoInfo = _repository.GetCompanyLogo(subdomainName);

            if (CompanylogoInfo.Count > 0)
            {
                foreach (var item in CompanylogoInfo)
                {
                    loginmodel.OrgId = item.OrgId;
                    loginmodel.OrgName = item.OrgName;
                    loginmodel.Logolocation = item.Logolocation;
                    loginmodel.Subdomain = subdomainName;
                    loginmodel.ThemeName = item.ThemeName;
                }
            }
            else
            {
                loginmodel.OrgId = 0;
                loginmodel.OrgName = string.Empty;
                if (System.Configuration.ConfigurationManager.AppSettings["DefaultcompanyLogo"] != null)
                {
                    loginmodel.Logolocation = System.Configuration.ConfigurationManager.AppSettings["DefaultcompanyLogo"].ToString();
                }
                else
                {
                    loginmodel.Logolocation = string.Empty;
                }

                loginmodel.Subdomain = subdomainName;
            }
            //http://localhost:51985

              //  need to uncomment for dynamic logo
            return View(loginmodel);
        }