public ActionResult Logout() { var formsAuthenticationServic = new FormsAuthenticationService(); formsAuthenticationServic.SignOut(); return(RedirectToAction("Login", "User")); }
/// <summary> /// 用户注销登陆 /// </summary> /// <returns></returns> public ActionResult Logout() { FormsAuthenticationService.SignOut(); Session.Clear(); Session.Abandon(); return(Redirect(FormsAuthenticationService.LoginUrl)); }
public ActionResult LoginOut() { //登出 FormsAuthenticationService.SignOut(); Session.Clear(); return(View("Login", new UserViewModel())); }
public ActionResult LogOff() { FormsAuthenticationService formAuth = new FormsAuthenticationService(); formAuth.SignOut(); return(RedirectToAction("Index", "Home")); }
public ActionResult Edit(Guid?id, PersonEditModel personEditModel, HttpPostedFileBase profilepic) { User user = null; // admin is trying to edit, authorize them if (id.HasValue) { // current user must be in User role if (Roles.IsUserInRole(RoleNames.User)) { user = _userRepository.GetNullableById(id.Value); } } else { user = Repository.OfType <User>().Queryable.Where(a => a.LoweredUserName == CurrentUser.Identity.Name.ToLower()).FirstOrDefault(); } if (user == null) { return(this.RedirectToAction <ErrorController>(a => a.NotAuthorized())); } //var seminarPerson = _seminarPersonRepository.GetNullableById(personEditModel.SeminarPersonId); var person = SetPerson(personEditModel, null, ModelState, user.Person, profilepic); var membership = user.Membership; membership.SetEmail(personEditModel.Email); if (ModelState.IsValid) { _personRepository.EnsurePersistent(person); _membershipRepository.EnsurePersistent(membership); Message = string.Format(Messages.Saved, "Person"); if (personEditModel.UserName != CurrentUser.Identity.Name.ToLower()) { user.SetUserName(personEditModel.UserName); _userRepository.EnsurePersistent(user); var formsService = new FormsAuthenticationService(); formsService.SignOut(); formsService.SignIn(user.LoweredUserName, false); } // send to crop photo if one was uploaded if (profilepic != null) { return(this.RedirectToAction(a => a.UpdateProfilePicture(person.Id, null, true))); } } var viewModel = PersonViewModel.Create(Repository, _firmService, Site, null, person, user.Email); return(View(viewModel)); }
public ActionResult Index(String returnUrl = null) { // 清除登录信息 FormsAuthenticationService.SignOut(); Session.Clear(); return(View(new UserViewModel() { ReturnUrl = returnUrl })); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var action = RouteData.Values["action"].ToString(); var userName = RouteData.Values["userName"].ToString(); if (SecurityContext.IsAuthenticated && (action == "signin" || action == "register")) { Response.RedirectToRoute("Default", null); return; } switch (action) { case "signin": this.pageActionType.Value = "signin"; this.signInButtons.Visible = true; this.username.Text = userName; this.rememberMeWrapper.Visible = true; break; case "register": this.pageActionType.Value = "register"; this.registerButtons.Visible = true; this.username.Attributes.Add("autocomplete", "off"); this.passwordReWrapper.Visible = true; break; case "signout": using (var formsAuthService = new FormsAuthenticationService(Context)) { formsAuthService.SignOut(); } Response.RedirectToRoute("Default", null); break; default: Response.RedirectToRoute("NotFound", null); break; } DataBind(); } }
public override void OnAuthorization(AuthorizationContext filterContext) { base.OnAuthorization(filterContext); if (filterContext.RequestContext.HttpContext.Request.IsAuthenticated) { IFormsAuthenticationService FormsService = new FormsAuthenticationService(); SessionHelper session = new SessionHelper(filterContext.HttpContext); if (session.SessionEndTime == null) { session.SessionEndTime = DateTime.Now; } else if (DateTime.Now - session.SessionEndTime > TimeSpan.FromMinutes(1)) { FormsService.SignOut(); filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary(new { controller = "Account", action = "Logon" })); } } }
protected override void Execute(System.Web.Routing.RequestContext requestContext) { Session = new SessionHelper(requestContext.HttpContext); if (!requestContext.HttpContext.Request.Url.AbsoluteUri.ToLower().Contains("service")) { if (requestContext.HttpContext.Request.IsAuthenticated) { IFormsAuthenticationService FormsService = new FormsAuthenticationService(); if (DateTime.Now - Session.SessionEndTime > TimeSpan.FromMinutes(20)) { FormsService.SignOut(); requestContext.HttpContext.Response.Redirect(requestContext.HttpContext.Request.Url.AbsoluteUri, true); } else { Session.SessionEndTime = DateTime.Now; } } } base.Execute(requestContext); }
protected void btnLogOut_Click(object sender, EventArgs e) { _authenticationService.SignOut(); Response.Redirect("~/home"); }