SignOut() 공개 메소드

public SignOut ( ) : void
리턴 void
예제 #1
0
        public ActionResult Logout()
        {
            var formsAuthenticationServic = new FormsAuthenticationService();

            formsAuthenticationServic.SignOut();
            return(RedirectToAction("Login", "User"));
        }
예제 #2
0
 /// <summary>
 /// 用户注销登陆
 /// </summary>
 /// <returns></returns>
 public ActionResult Logout()
 {
     FormsAuthenticationService.SignOut();
     Session.Clear();
     Session.Abandon();
     return(Redirect(FormsAuthenticationService.LoginUrl));
 }
예제 #3
0
 public ActionResult LoginOut()
 {
     //登出
     FormsAuthenticationService.SignOut();
     Session.Clear();
     return(View("Login", new UserViewModel()));
 }
예제 #4
0
        public ActionResult LogOff()
        {
            FormsAuthenticationService formAuth = new FormsAuthenticationService();

            formAuth.SignOut();
            return(RedirectToAction("Index", "Home"));
        }
예제 #5
0
        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));
        }
예제 #6
0
 public ActionResult Index(String returnUrl = null)
 {
     // 清除登录信息
     FormsAuthenticationService.SignOut();
     Session.Clear();
     return(View(new UserViewModel()
     {
         ReturnUrl = returnUrl
     }));
 }
예제 #7
0
        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();
            }
        }
예제 #8
0
        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" }));
                }
            }
        }
예제 #9
0
        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);
        }
예제 #10
0
 protected void btnLogOut_Click(object sender, EventArgs e)
 {
     _authenticationService.SignOut();
     Response.Redirect("~/home");
 }