예제 #1
0
        /// <summary>
        /// Login the user and redirect to private data
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public ActionResult Login(string username, string password)
        {
            var isLoggedIn = MvcFormsSecurityProvider.LoginUser(username, password, true);

            if (isLoggedIn)
            {
                return(RedirectToAction(@"PrivateData"));
            }
            return(RedirectToAction(@"Index"));
        }
예제 #2
0
        /// <summary>
        /// Register new user
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public ActionResult Register(string username, string password)
        {
            var user = new User();

            user.Username = username;
            user.Email    = string.Format(@"{0}@gmail.com", username);
            user.Password = password;

            var userRegistrationResult = DomainServices.User.Register(user);

            if (userRegistrationResult.IsFaulted)
            {
                return(this.CreateFaultedResult(userRegistrationResult));
            }
            MvcFormsSecurityProvider.LoginUser(username, password, true);
            return(RedirectToAction(@"PrivateData"));
        }
예제 #3
0
 /// <summary>
 /// Logut the user from the system
 /// </summary>
 /// <param name="username"></param>
 /// <param name="password"></param>
 /// <returns></returns>
 public ActionResult Logout(string username, string password)
 {
     MvcFormsSecurityProvider.Logout();
     return(RedirectToAction(@"Index"));
 }
예제 #4
0
 protected void Application_AuthenticateRequest(Object sender, EventArgs e)
 {
     // check for ticket renewals and set the current principal
     MvcFormsSecurityProvider.SetCurrentPrincipalAndPrincipalTicket();
 }