ValidateUser() public static method

public static ValidateUser ( string username, string password ) : bool
username string
password string
return bool
コード例 #1
0
ファイル: Login.aspx.cs プロジェクト: vsisdead/DotNetAppDev
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack)
     {
         var loginVm = new LoginVm();
         if (TryUpdateModel(loginVm, new FormValueProvider(ModelBindingExecutionContext)) &&
             (UserManager.ValidateUser(loginVm.Username, loginVm.Password) && ModelState.IsValid))
         {
             FormsAuthentication.RedirectFromLoginPage(loginVm.Username, false);
         }
     }
     else if (Request.IsAuthenticated)
     {
         Response.StatusCode      = 403;
         Response.SuppressContent = true;
         Context.ApplicationInstance.CompleteRequest();
     }
 }
コード例 #2
0
ファイル: Login.aspx.cs プロジェクト: chean521/302CEM_Project
        protected void User_Login_Authenticate(object sender, AuthenticateEventArgs e)
        {
            var            Logins = sender as System.Web.UI.WebControls.Login;
            MembershipUser User   = Members.GetUser(Logins.UserName);

            if (Members.ValidateUser(User_Login.UserName, User_Login.Password) == true)
            {
                String Role = "";

                if (HttpContext.Current.User.IsInRole("Administrator"))
                {
                    Role = "Administrator";
                }
                if (HttpContext.Current.User.IsInRole("Manager"))
                {
                    Role = "Manager";
                }
                if (HttpContext.Current.User.IsInRole("Users"))
                {
                    Role = "Users";
                }

                var        ticket = new FormsAuthenticationTicket(1, User_Login.UserName, DateTime.Now, DateTime.Now.AddMinutes(2880), User_Login.RememberMeSet, Role, FormsAuthentication.FormsCookiePath);
                String     hash   = FormsAuthentication.Encrypt(ticket);
                HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hash);

                if (ticket.IsPersistent)
                {
                    cookie.Expires = ticket.Expiration;
                }

                DateTime Last_Login = User.LastLoginDate;

                Response.Cookies.Add(cookie);
                Session["Status"]    = true;
                Session["LastLogin"] = Last_Login;
                Response.Redirect(FormsAuthentication.GetRedirectUrl(User_Login.UserName, User_Login.RememberMeSet));
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Invalid login details.');", true);
            }
        }
コード例 #3
0
ファイル: Login.aspx.cs プロジェクト: simple555a/DotNetAppDev
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack)
     {
         string user   = Request["userName"];
         string pass   = Request["pass"];
         string action = Request["action"];
         if (action == "login" && UserManager.ValidateUser(user, pass))
         {
             FormsAuthentication.RedirectFromLoginPage(user, false);
         }
         else
         {
             message.Style["visibility"] = "visible";
         }
     }
     else if (Request.IsAuthenticated)
     {
         Response.StatusCode      = 403;
         Response.SuppressContent = true;
         Context.ApplicationInstance.CompleteRequest();
     }
 }