public bool Authenticate(string username, string password)
        {
            bool isAuthenticated = FormsAuthentication.Authenticate(username, password);

            if (isAuthenticated)
            {
                FormsAuthentication.SetAuthCookie(username, false);
            }

            return(isAuthenticated);
        }
Beispiel #2
0
        public bool Auth(string username, string password)
        {
#pragma warning disable 618
            var result = FormsAuthentication.Authenticate(username, password);
#pragma warning restore 618
            if (result)
            {
                FormsAuthentication.SetAuthCookie(username, false);
            }

            return(result);
        }
Beispiel #3
0
 protected bool IsDefaultPassword()
 {
     try
     {
         return(FormsAuthentication.Authenticate("admin", "changeme") ||
                System.Web.Security.Membership.ValidateUser("admin", "changeme"));
     }
     catch (Exception)
     {
         return(false);
     }
 }
 protected void btnLogin_Click(object sender, EventArgs e)
 {
     // Authenticate the user.
     if (FormsAuthentication.Authenticate(txtUserName.Text, txtPassword.Text))
     {
         FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, false);
     }
     else
     {
         lblErrorMessage.Text = "The user name and password should be \"suser\" and \"password\".";
     }
 }
 public ActionResult LogOn(string username, string password)
 {
     if (FormsAuthentication.Authenticate(username, password))
     {
         FormsAuthentication.SetAuthCookie(username, false);
         return(Redirect(FormsAuthentication.GetRedirectUrl(username, false)));
     }
     else
     {
         return(View("LogOn"));
     }
 }
Beispiel #6
0
    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
        if (FormsAuthentication.Authenticate(Login1.UserName, Login1.Password))
        {
            FormsAuthentication.RedirectFromLoginPage(Login1.UserName, false);
        }

        else
        {
            Login1.FailureText = "you are not authorized to view the page";
        }
    }
        /// <summary>
        /// 认证
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public bool Auth(string userName, string password)
        {
            var result = FormsAuthentication.Authenticate(userName, password);

            if (result)
            {
                //设置认证 Cookie
                FormsAuthentication.SetAuthCookie(userName, false);
            }

            return(result);
        }
Beispiel #8
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (FormsAuthentication.Authenticate(useremail.Text, userpassword.Text))
     {
         FormsAuthentication.RedirectFromLoginPage
             (useremail.Text, Persist.Checked);
     }
     else
     {
         Msg.Text = "Invalid credentials. Please try again.";
     }
 }
Beispiel #9
0
 protected void btnLogIn_Click(object sender, EventArgs e)
 {
     if (FormsAuthentication.Authenticate(txtUsername.Text, txtPassword.Text))
     {
         FormsAuthentication.RedirectFromLoginPage(txtUsername.Text, false);
     }
     else
     {
         lblMensaje.Text    = "Usuario o Clave incorrecto";
         lblMensaje.Visible = true;
     }
 }
        public ActionResult Login(string username, string password, string returnUrl)
        {
            bool result = FormsAuthentication.Authenticate(username, password);

            if (result)
            {
                FormsAuthentication.SetAuthCookie(username, false);
                return(Redirect(Url.Action("Index", "Home")));
            }
            ModelState.AddModelError("", "Некорректное имя пользователя или пароль");
            return(View());
        }
        public bool Authenticate(string username, string password)
        {
#pragma warning disable CS0618 // Тип или член устарел
            bool result = FormsAuthentication.Authenticate(username, password);
#pragma warning restore CS0618 // Тип или член устарел

            if (result)
            {
                FormsAuthentication.SetAuthCookie(username, false);
            }
            return(result);
        }
Beispiel #12
0
 protected void loginButton_Click(object sender, EventArgs e)
 {
     if (FormsAuthentication.Authenticate(username.Text, password.Text))
     {
         FormsAuthentication.RedirectFromLoginPage(username.Text, true);
     }
     else
     {
         loginLabel.Text = "Invalid user!" +
                           "\nPlease, enter admin(Username: comp229, password:comp229)";
     }
 }
Beispiel #13
0
        //user authentication
        public bool Authenticate(string username, string password)
        {
            //set the authentican
            bool result = FormsAuthentication.Authenticate(username, password);

            if (result)
            {
                //set cookies
                FormsAuthentication.SetAuthCookie(username, false);
            }
            return(result);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string userEmail = "*****@*****.**";
            string password  = "******";

            if (Membership.ValidateUser(userEmail, password))
            {
                FormsAuthentication.SetAuthCookie(userEmail, true);
                FormsAuthentication.Authenticate(userEmail, password);
                Response.Redirect("../Default.aspx");
            }
        }
Beispiel #15
0
        public ActionResult Login(User user)
        {
            if (this.ModelState.IsValid && FormsAuthentication.Authenticate(user.Login, user.Password))
            {
                FormsAuthentication.SetAuthCookie(user.Login, false);
                return(RedirectToAction("Index", "Promo"));
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "Incorrect username or password.");
            return(View(user));
        }
Beispiel #16
0
        protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            string u = Login1.UserName;
            string p = Login1.Password;

            if (FormsAuthentication.Authenticate(u, p))
            {
                //FormsAuthentication.Authenticate(u,p)如果為true
                e.Authenticated = true;                             //表示驗證成功
                FormsAuthentication.RedirectFromLoginPage(u, true); //帳號紀錄到cookie中
            }
        }
        protected void LoginUser(object sender, EventArgs e)
        {
            //if(username.Text == "username" && password.Text == "password")
            //{
            //    FormsAuthentication.RedirectFromLoginPage(username.Text, false);
            //}

            if (FormsAuthentication.Authenticate(username.Text, password.Text))
            {
                FormsAuthentication.RedirectFromLoginPage(username.Text, false);
            }
        }
Beispiel #18
0
        public ActionResult Login(LoginUser user)
        {
            bool result = FormsAuthentication.Authenticate(user.UserName, user.Password);

            if (result)
            {
                FormsAuthentication.SetAuthCookie(user.UserName, false);
                return(Redirect("/Admin/Index"));
            }
            ModelState.AddModelError("", "Неверный логин или пароль");
            return(View());
        }
Beispiel #19
0
 protected void loginButton_Click(object sender, EventArgs e)
 {
     // NB. The authenticated user's name must correspond to a user configured within Google Apps.
     if (FormsAuthentication.Authenticate(usernameTextBox.Text, passwordTextBox.Text))
     {
         FormsAuthentication.RedirectFromLoginPage(usernameTextBox.Text, false);
     }
     else
     {
         errorMessageLabel.Text = "Invalid credentials. The user name and password should be \"google\" and \"password\".";
     }
 }
Beispiel #20
0
        //[ValidateAntiForgeryToken]
        public virtual ActionResult Login(LoginModel model, string returnUrl)
        {
            if (FormsAuthentication.Authenticate(model.UserName, model.Password))
            {
                FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                return(Redirect(returnUrl ?? FormsAuthentication.DefaultUrl));
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return(View(model));
        }
Beispiel #21
0
 protected void Login_Click(object sender, EventArgs e)
 {
     if (FormsAuthentication.Authenticate(wf_Username.Text, wf_Password.Text))
     {
         FormsAuthentication.RedirectFromLoginPage(wf_Username.Text, true);
     }
     else
     {
         wf_Status.Text   += "Invalid Login";
         wf_Status.Visible = true;
     }
 }
Beispiel #22
0
 private void btnLogin_Click(object sender, System.EventArgs e)
 {
     if (FormsAuthentication.Authenticate(tbUserName.Text, tbPassword.Text))
     {
         FormsAuthentication.SetAuthCookie(tbUserName.Text, false);
         FormsAuthentication.RedirectFromLoginPage(tbUserName.Text, false);
     }
     else
     {
         lMsg.Text = "<b>Something went wrong...</b> please re-enter your credentials...";
     }
 }
Beispiel #23
0
        public bool Authenticate(string username, string password)
        {
            //obsolete
            bool result = FormsAuthentication.Authenticate(username, password);

            //bool result = Membership.ValidateUser(username, password);
            if (result)
            {
                FormsAuthentication.SetAuthCookie(username, false);
            }
            return(result);
        }
Beispiel #24
0
 protected void btnLogin_Click(object sender, EventArgs e)
 {
     if (FormsAuthentication.Authenticate(txtUserName.Text, txtPassword.Text))
     {
         // Create the authentication cookie and redirect the user to welcome page
         FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, false);
     }
     else
     {
         Response.Write("Invalid UserName and/or password");
     }
 }
Beispiel #25
0
        public virtual ActionResult Login(LoginViewModel model, string returnUrl)
        {
            if (ModelState.IsValid && FormsAuthentication.Authenticate(model.UserName, model.Password))
            {
                FormsAuthentication.SetAuthCookie(model.UserName, false);
                return(RedirectToLocal(returnUrl));
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return(View(Views.Login, model));
        }
 protected void Button1_Click(object sender, EventArgs e)
 {
     // if ((txtUsuario.Text == "demo") && (txtPassword.Text == "1234"))
     if (FormsAuthentication.Authenticate(txtUsuario.Text, txtPassword.Text))
     {
         FormsAuthentication.RedirectFromLoginPage(txtUsuario.Text, chckbxRecordarme.Checked);
     }
     else
     {
         lblnoAutenticado.Text = " Usuario no autorizado";
     }
 }
Beispiel #27
0
 protected void btnKirjaudu_Click(object sender, EventArgs e)
 {
     if (FormsAuthentication.Authenticate(this.txtKayttaja.Text, this.txtSala.Text))
     {
         FormsAuthentication.SetAuthCookie(this.txtKayttaja.Text, false);
         FormsAuthentication.RedirectFromLoginPage(this.txtKayttaja.Text, false);
     }
     else
     {
         lblKirjautuminen.Text = "Invalid login details. Please try again.";
     }
 }
Beispiel #28
0
        public virtual bool Authenticate(string username, string password)
        {
            bool result = FormsAuthentication.Authenticate(username, password);

            if (result)
            {
                FormsAuthentication.SetAuthCookie(username, false);
            }

            FormsAuthentication.SetAuthCookie(username, false);
            return(true);
        }
Beispiel #29
0
 protected void BtnLogonWebConfig_Click(object sender, EventArgs e)
 {
     //Authenticating against values in Web.config
     if (FormsAuthentication.Authenticate(UserEmail.Text, UserPass.Text))
     {
         FormsAuthentication.RedirectFromLoginPage(UserEmail.Text, Persist.Checked);
     }
     else
     {
         Message.Text = "Invalid credentials. Please try again";
     }
 }
 protected void Login_Click(object sender, EventArgs e)
 {
     if (FormsAuthentication.Authenticate(TextBox1.Text, TextBox2.Text))
     {
         FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, false);
         //Response.Redirect("Main_form.aspx");
     }
     else
     {
         Label3.Text = "Invalid user name or password";
     }
 }