public async Task <ActionResult> Login(LoginModel model) { if (!ModelState.IsValid) { return(View(model)); } if (!VeryfyCodeUtility.IsVerifyCodeMatch(Session, model.ValidateCode)) { ModelState.AddModelError("ValidateCode", "验证码错误!"); return(View(model)); } var loginResult = await UsersRepository.Login(model.UserName, model.Password); if (loginResult.Status == SigninStatus.Succ) { FormsAuthSvc.CreateAuthenticationTicket(loginResult.UserInfo, Response, HttpContext, model.IsRemember); //添加到Fom if (model.IsRemember) { CookieUtils.SetCookie(FormsAuthSvc.GetUserNameCookieKey(), model.UserName, true); } else { CookieUtils.RemoveCookie(FormsAuthSvc.GetUserNameCookieKey()); } //添加登录日志 await SysOperationLogRepository.Insert(TableSource.Users, OperationType.UserLogin, "", ""); return(Redirect(Url.AdminHome())); } ModelState.AddModelError("UserName", "登录失败!" + loginResult.Status.GetDescriotion()); return(View(model)); }
public ActionResult AuthResponse(string token) { var sessionToken = AuthSubUtil.exchangeForSessionToken(token, null); var settings = _siteSettingsService.GetSettings(); settings.AnalyticsToken = sessionToken; Db.Save(settings); Cache.Trigger(TriggerFor.Id <SiteSettings>(settings.Id)); return(Redirect(Url.AdminHome())); }
public ActionResult Login() { if (User.Identity.IsAuthenticated) { return(Redirect(Url.AdminHome())); } var model = new LoginModel(); model.UserName = CookieUtils.GetCookie(FormsAuthSvc.GetUserNameCookieKey(), ""); if (!string.IsNullOrEmpty(model.UserName)) { model.IsRemember = true; } return(View(model)); }
public ActionResult AnalyticsConfig(Config model) { var settings = _siteSettingsService.GetSettings(); var profiles = GetProfiles(settings); var profile = profiles.SingleOrDefault(x => x.Id == model.ProfileId); if (profile == null) { throw new Exception("Unable to find the specified analytics profile: " + model.ProfileId); } settings.AnalyticsProfileId = profile.Id; Db.Save(settings); Cache.Trigger(TriggerFor.Id <SiteSettings>(settings.Id)); return(Redirect(Url.AdminHome())); }
public ActionResult Index() { return(Redirect(Url.AdminHome())); }