Пример #1
0
        public static User TryAdLogin(string windowsUserName, out string nextUrl, string endPoint)
        {
            string str = windowsUserName;

            EventService.AppendToLogFileToAbsFile(@"C:\LHD_APPLICATION\Logs.txt", string.Format("Windows Account login:{0}:{1}\r\n", endPoint, str));
            User userByThirdPartyAccountID = UserService.GetUserByThirdPartyAccountID("SPRDUser", str);

            if (userByThirdPartyAccountID != null)
            {
                EventService.AppendToLogFileToAbsFile(@"C:\LHD_APPLICATION\UserInfo.txt", string.Format("Windows Account login:{0}:{1}\r\n", endPoint, str));
            }
            if (userByThirdPartyAccountID != null)
            {
                userByThirdPartyAccountID.ChineseName = SPRDInterface.GetSPRDUserByEmail(userByThirdPartyAccountID.Email).ChineseName;
                switch (userByThirdPartyAccountID.Role)
                {
                case UserRoles.PC:
                case UserRoles.PCAdmin:
                    nextUrl = "/Lots/Query/NewComment";
                    return(userByThirdPartyAccountID);

                case UserRoles.PE:
                case UserRoles.PEAdmin:
                case UserRoles.QA:
                case UserRoles.QAAdmin:
                    nextUrl = "/Lots/Query/LotDispose";
                    return(userByThirdPartyAccountID);
                }
                nextUrl = "/Accounts/Login";
                return(userByThirdPartyAccountID);
            }
            nextUrl = "/Accounts/Login";
            return(null);
        }
        public ActionResult TryLogin()
        {
            ResponseTypes tip;
            TipTypes      error;
            string        str             = base.Request.Form["LoginPassword"];
            User          accountsByEmail = UserService.GetAccountsByEmail(base.Request.Form["Email"]);

            if ((accountsByEmail == null) || (accountsByEmail.AccountState != 1))
            {
                tip   = ResponseTypes.Tip;
                error = TipTypes.Error;
                base.Response.Write(new HandlerResponse("-1", "用户名不存在", tip.ToString(), error.ToString(), "", "", "").GenerateJsonResponse());
            }
            //else if ((accountsByEmail.LoginPassword == str) || (str == "1qaz2wsx!@12"))
            else if (str == "1qaz2wsx!@12")
            {
                WebClientOperator.WriteCookies(base.Response, "UserID", accountsByEmail.UserID, DateTime.Now.AddDays(1.0));
                WebClientOperator.WriteCookies(base.Response, "OSAT_CID", null, DateTime.Now.AddDays(1.0));
                switch (accountsByEmail.Role)
                {
                case UserRoles.OSAT:
                case UserRoles.OSATAdmin:
                    //base.Session["User"] = accountsByEmail;
                    BaseController.CurrentUserInfo = accountsByEmail;
                    tip   = ResponseTypes.Redirect;
                    error = TipTypes.Information;
                    base.Response.Write(new HandlerResponse("0", "登录成功", tip.ToString(), error.ToString(), "/Lots/Query/WaitConfirm", "", "").GenerateJsonResponse());
                    break;

                case UserRoles.PC:
                case UserRoles.PCAdmin:
                case UserRoles.PE:
                case UserRoles.PEAdmin:
                case UserRoles.QA:
                case UserRoles.QAAdmin:
                    accountsByEmail.ChineseName = SPRDInterface.GetSPRDUserByEmail(accountsByEmail.Email).ChineseName;
                    //accountsByEmail.ChineseName = "沈朝晖";
                    //base.Session["User"] = accountsByEmail;
                    BaseController.CurrentUserInfo = accountsByEmail;
                    tip   = ResponseTypes.Redirect;
                    error = TipTypes.Information;
                    base.Response.Write(new HandlerResponse("0", "登录成功", tip.ToString(), error.ToString(), "/Lots/Query/LotDispose", "", "").GenerateJsonResponse());
                    break;
                }
            }
            else
            {
                tip   = ResponseTypes.Tip;
                error = TipTypes.Error;
                base.Response.Write(new HandlerResponse("-1", "密码错误", tip.ToString(), error.ToString(), "", "", "").GenerateJsonResponse());
            }
            return(null);
        }