Ejemplo n.º 1
0
        private JsonResult LogonInternal(LogOnView model, string returnUrl, string authCode, Action setUIMode)
        {
            var type = 0;
            var result = false;

            //if (ModelState.IsValid && AuthCodeService.ForceVerify(authCode) == AuthenticationResultType.Successful)
            if (ModelState.IsValid && _authCodeValidateService.validateAuthCode(authCode))
            {
                //msg = "You did not type the verification word correctly. Please try again.";
                //var isValidUser = Membership.ValidateUser(model.UserName, model.Password);
                var isValidUser = _membershipService.ValidateUser(model.UserName, model.Password);
                //AuthCodeService.Login(isValidUser);
                _authCodeValidateService.Login(isValidUser);

                if (isValidUser)
                {
                    result = true;
                    setUIMode();
                    //FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                    _formsAuthenticationService.SetAuthCookie(model);

                    if (model.RememberMe)
                    {
                        cookieService.Set("RememberMe", model.RememberMe.ToString(), CookieTimeoutSeconds);
                    }
                    else
                    {
                        cookieService.Remove("RememberMe");
                    }
                }
                else
                {
                    type = LOGIN_ERROR_USER_OR_PASSWORD_NOT_CORRECT;
                    //var user = Membership.GetUser(model.UserName);
                    var user = _membershipService.GetUser(model.UserName);
                    if (user != null && user.IsLockedOut) type = LOGIN_ERROR_TOO_MANY_FAILURES;
                }
            }
            else
            {
                type = LOGIN_ERROR_AUTHCODE_NOT_CORRECT;
            }

            return Json(new { msgType = type, url = returnUrl, ret = result });
        }
Ejemplo n.º 2
0
        private string GetReturnUrl(LogOnView model, string returnUrl)
        {
            var brandOTAUrl = "/OTAUI/AppManage";
            var pcbaOTAUrl = "/NewOTAUI/AppManage";

            if (model != null)
            {
                var currentDesignCompany = _userAccessDataControlService.GetDesignCompaniesByUser(model.UserName).FirstOrDefault();
                var currentDesignCompanyName = currentDesignCompany.Name;
                returnUrl = currentDesignCompanyName.Contains(DESIGN_COMPANGY_TYPE) ? brandOTAUrl : pcbaOTAUrl;
            }
            return returnUrl;
        }
Ejemplo n.º 3
0
        public ActionResult LogOnOTA(LogOnView model, string returnUrl, string authCode)
        {
            returnUrl = GetReturnUrl(model, returnUrl);

            return LogonInternal(model, returnUrl, authCode, () => cookieService.Set("UIMode", "OTA", CookieTimeoutSeconds));
        }
Ejemplo n.º 4
0
        public ActionResult LogOn(LogOnView model, string returnUrl, string authCode)
        {
            if (returnUrl.IsNullOrEmpty()) returnUrl = "/AppStoresUI/AppManage";

            return LogonInternal(model, returnUrl, authCode, () => cookieService.Set("UIMode", "AppStore", CookieTimeoutSeconds));
        }
 private void SaveCookie(LogOnView model)
 {
     Redis.SetEntryInHash<string>("Cookies", EncryptionHelper.EncryptUrl(model.UserName), EncryptionHelper.EncryptUrl(model.Password));
 }
 public void SetAuthCookie(LogOnView model)
 {
     SaveCookie(model);
        FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
 }