public bool AuthorizationRequest(HttpContextBase httpContext) { if (httpContext.Session["XzUserLogin"] == null && httpContext.Session["AdminUserLogin"] == null) { return(false); } else { if (httpContext.Session["XzUserLogin"] != null) { var ad = new AdministratorObject { Account = httpContext.Session["XzUserLogin"].ToString(), Authority = "校长" }; httpContext.Session["AdministratorObject"] = ad; } else { ISchoolAdministratorDal administratorDal = new SchoolAdministratorDal(ConfigurationManager.AppSettings["assembly"]); IGetEntity getEntity = new GetEntity(); var entity = getEntity.GetEntityForKey(httpContext.Session["AdminUserLogin"].ToString(), administratorDal); var ad = new AdministratorObject() { Account = httpContext.Session["AdminUserLogin"].ToString(), Authority = entity.CreateAdminitratorDetialDatas.AdministratorAuthority, }; httpContext.Session["AdministratorObject"] = ad; } return(true); } }
public ActionResult GetEmailValidateCode(LogInModel model, string ValidateCode, string Option = "administartor") { bool isValidateForSend = false; bool sendIsOk = false; //发送验证码 ICreateEmail sendEmail = new CreateEnail(); IGetEntity getEntity = new GetEntity(); //创建四位随机码 String validateCode = CreateValidateCode.CreateValidateCodes(); try { if (model.Account == null || model.Password == null) { return(JavaScript("")); } Session["Administartor"] = validateCode; ILoinValidate log = new LoginValidate(); if (sendIsOk == false && log.ValidateAccount(model, option: Option)) { var entity = getEntity.GetEntityForKey(model.Account, accountSchoolDal); sendIsOk = sendEmail.SeendEmail(entity.AdministratorAccount, entity.CreateAdminitratorDetialDatas.Email, validateCode, "登陆验证"); } } catch (Exception e) { isValidateForSend = false; } if (sendIsOk) { var createCookie = new CreateCooks(); //创建Cookie var cookie = createCookie.CreateCooki(5); HttpContext.Response.Cookies.Add(cookie); isValidateForSend = true; } if (isValidateForSend) { var str = CreateJavaScript.CreateJS(5); return(JavaScript(str)); } return(new HttpStatusCodeResult(400)); }