Пример #1
0
        public ActionResult Login(LoginViewModel model, string Remember)
        {
            Personal  personal  = _personalService.GetPersonalByLogin(model.EMail, model.Password);
            Corporate corporate = _corporateService.GetCorporateByLogin(model.EMail, model.Password);

            if (personal != null)
            {
                Session["personal"]   = personal;
                Session["personalID"] = personal.ID;
                if (Remember == "on")
                {
                    FormsAuthentication.RedirectFromLoginPage(model.EMail, true);
                }
                else
                {
                    FormsAuthentication.RedirectFromLoginPage(model.EMail, false);
                }
                if (personal.UserRoleID == 1)
                {
                    return(RedirectToAction("ListPersonal", "Admin"));
                }
                else
                {
                    return(RedirectToAction("Profil", "PersonalProfil", new { id = personal.ID }));
                }
            }
            else if (corporate != null)
            {
                Session["corporate"] = corporate;
                return(RedirectToAction("CorparateProfil", "Corporate"));
            }
            else
            {
                ViewBag.Message = "!!Hatalı giriş yaptınız.Tekrar deneyin.";
            }
            return(View());
        }
Пример #2
0
        protected void LoginButton_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                string sanitisedEmail = EmailTextBox.Text.ToLower().Trim();
                string password       = PasswordTextBox.Text;

                //Get the user details so we can check if the user exists or if the password is incorrect.

                Admin current_user = Admin.GetAdminsByEmail(sanitisedEmail);

                if (current_user != null)
                {
                    string password_hash = BusinessHelper.computeSHAhash(password, current_user.creation_datetime);

                    if (current_user.email == sanitisedEmail && current_user.password_hash == password_hash)
                    {
                        Session["admin_id"]    = current_user.admin_id;
                        Session["admin_email"] = current_user.email;
                        FormsAuthentication.SetAuthCookie(sanitisedEmail, false);
                        FormsAuthentication.RedirectFromLoginPage(current_user.email, false);

                        Response.Redirect("~/manage/SelectCompany.aspx");
                    }
                    else
                    {
                        //Last option is that password was incorrect.
                        LoginErrorLabel.Text = "Incorrect  Email & Password Combination. Check that CAPS-LOCK is off. ";
                    }
                }
                else
                {
                    //Username not found
                    LoginErrorLabel.Text = "Your email address was not found. Please check the spelling or create a new account.";
                }
            }
        }
    protected void Loginctrl_Authenticate(object sender, AuthenticateEventArgs e)
    {
        string result = Authentication.Utility.Login(Loginctrl.UserName.ToString(), Loginctrl.Password.ToString(), dm.Subdm);

        DataSet ds;

        Session["User"] = Loginctrl.UserName.ToString();
        switch (result)
        {
        case "USER":
            e.Authenticated         = true;
            Session["Authenticate"] = "Approved";
            ds = Authentication.Utility.Logininfo(Loginctrl.UserName.ToString(), Loginctrl.Password.ToString());
            Session["Admin_Customer"] = ds.Tables[0].Rows[0]["Customer_Id"].ToString();
            Session["Admin_Type"]     = "USER";
            FormsAuthentication.RedirectFromLoginPage(Loginctrl.UserName, Loginctrl.RememberMeSet);
            Response.Redirect("~/secure/Home.aspx");
            break;

        case "ADMIN":
            e.Authenticated         = true;
            Session["Authenticate"] = "Approved";
            ds = Authentication.Utility.Logininfo(Loginctrl.UserName.ToString(), Loginctrl.Password.ToString());
            Session["Admin_Customer"] = ds.Tables[0].Rows[0]["Customer_Id"].ToString();
            //Session["Customer_id"] = ds.Tables[0].Rows[0]["Customer_Id"].ToString();
            Session["Admin_Type"] = "ADMIN";
            FormsAuthentication.RedirectFromLoginPage(Loginctrl.UserName, Loginctrl.RememberMeSet);
            Response.Redirect("~/secure/Home.aspx");
            break;

        case "Access_Denied":
            e.Authenticated         = false;
            Session["Authenticate"] = "Declined";
            Session["Admin_Type"]   = "Declined";
            break;
        }
    }
        public bool LogIn(string userEmail, string password, bool remember = false, bool redirect = true)
        {
            User user;

            if (userEmail.Contains("@"))
            {
                user = _userRepository.Filter(x => x.Email.Equals(userEmail)).FirstOrDefault();
            }
            else
            {
                var people   = _peopleRepository.Filter(x => x.IdNumber.Equals(userEmail)).FirstOrDefault();
                var withUser = people as PeopleWithUser;
                if (withUser != null)
                {
                    user = withUser.User;
                }
                else
                {
                    return(false);
                }
            }
            if (user == null)
            {
                return(false);
            }
            if (!user.CheckPassword(password))
            {
                return(false);
            }
            UpdateSessionFromUser(user);
            if (redirect)
            {
                // FormsAuthentication.SetAuthCookie(user.Email, remember);
                FormsAuthentication.RedirectFromLoginPage(user.Id.ToString(CultureInfo.InvariantCulture), remember);
            }
            return(true);
        }
Пример #5
0
    protected void BtnEntrar_Click(object sender, EventArgs e)
    {
        if ((tbxUsuario.Text.ToLower() == "cave") && (tbxSenha.Text.ToLower() == "cave"))
        {
            FormsAuthentication.RedirectFromLoginPage("cave", false);
        }
        else
        {
            lblErro.Visible = true;
            lblErro.Text    = "Login / senha inválidos";
        }

        /*int erro;
         * Usuario usuario = new Usuario();
         * DAOUsuario daousuario = new DAOUsuario();
         * usuario.Login = tbxUsuario.Text;
         * usuario.Senha = tbxSenha.Text;
         * erro = daousuario.validarLogin(usuario);
         * switch (erro)
         * {
         *  case 0:
         *      FormsAuthentication.RedirectFromLoginPage(usuario.Login, false);
         *      break;
         *  case 3:
         *      lblErro.Visible = true;
         *      lblErro.Text = "Senha inválida";
         *      break;
         *  case 4:
         *      lblErro.Visible = true;
         *      lblErro.Text = "Usuário desativado";
         *      break;
         *  case 5:
         *      lblErro.Visible = true;
         *      lblErro.Text = "Login não encontrado";
         *      break;
         * }*/
    }
Пример #6
0
        private void AuthenticateUser(string username, string password)
        {
            // ConfigurationManager class is in System.Configuration namespace
            string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;

            // SqlConnection is in System.Data.SqlClient namespace
            using (SqlConnection con = new SqlConnection(CS))
            {
                SqlCommand cmd = new SqlCommand("spAuthenticateUser", con);
                cmd.CommandType = CommandType.StoredProcedure;

                //Formsauthentication is in system.web.security
                //string encryptedpassword = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "SHA1");

                //sqlparameter is in System.Data namespace
                SqlParameter paramUsername = new SqlParameter("@UserName", username);
                SqlParameter paramPassword = new SqlParameter("@Password", password);

                cmd.Parameters.Add(paramUsername);
                cmd.Parameters.Add(paramPassword);

                con.Open();
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    if (Convert.ToBoolean(rdr["AccountLocked"]))
                    {
                        lblMessage.Text = "Account locked. Please contact administrator";
                    }

                    else if (Convert.ToBoolean(rdr["Authenticated"]))
                    {
                        FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, chkBoxRememberMe.Checked);
                    }
                }
            }
        }
Пример #7
0
        protected void btnSignIn_Click(object sender, EventArgs e)
        {
            lblmsg.Visible = true;
            try
            {
                con = new SqlConnection(constr);
                cmd = new SqlCommand
                {
                    CommandText = "select UserName from UserDetails where UserName=@un and UserPwd=@upw",
                    Connection  = con
                };
                cmd.Parameters.AddWithValue("@un", txtName.Text);
                cmd.Parameters.AddWithValue("@upw", txtPwd.Text);
                con.Open();
                srdr = cmd.ExecuteReader();
                if (srdr.HasRows)
                {
                    FormsAuthentication.RedirectFromLoginPage(txtName.Text, true);
                    if ((txtName.Text != null) && (txtPwd.Text != null))
                    {
                        lblmsg.Text = "Thank you for registering";
                    }
                }

                else
                {
                    lblmsg.Text = "Login Failed";
                }
                Response.Redirect("SignIN.aspx");
            }

            catch (Exception ex)
            {
                lblmsg.Text = "Error" + ex.Message;
                con.Close();
            }
        }
Пример #8
0
        private void SaveInformation(string pToken, string pTokenSecret, string pPass, string pName, string pEmail,
                                     LoginType pLoginType)
        {
            var session = HttpContext.Current.Session;

            if (session[LGTConsts.LGTApplicationVariableName.LoggedUserKey] != null)
            {
                return;
            }
            var args = new LGTExecuteLoginEventArgs
            {
                Autenticated = pLoginType != LoginType.Owner,
                Email        = pEmail,
                Pass         = pPass,
                Name         = pName,
                LoginType    = pLoginType
            };

            if (pLoginType == LoginType.Owner)
            {
                args = InvokeExecuteLogin(args);
            }
            if (args.Autenticated)
            {
                session[LGTConsts.LGTApplicationVariableName.LoggedUserKey] = new LoggedInformation
                {
                    Token       = pToken,
                    TokenSecret = pTokenSecret,
                    Name        = pName,
                    Email       = pEmail,
                    LoginType   = pLoginType,
                    Key         = args.Id
                };

                FormsAuthentication.RedirectFromLoginPage(string.IsNullOrEmpty(pName) ? pEmail : pName, false);
            }
        }
Пример #9
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        //    if (Membership.ValidateUser(tbUserName.Text, tbPassword.Text)) {
        //        if(string.IsNullOrEmpty(Request.QueryString["ReturnUrl"])) {
        //            FormsAuthentication.SetAuthCookie(tbUserName.Text, false);
        //            Response.Redirect("~/");
        //        }
        //        else
        //            FormsAuthentication.RedirectFromLoginPage(tbUserName.Text, false);
        //    }
        //    else {
        //        tbUserName.ErrorText = "Invalid user";
        //        tbUserName.IsValid = false;
        //    }
        NguoiDung nd   = new NguoiDung();
        string    user = tbUserName.Text;
        string    pass = tbPassword.Text;
        int       kq   = cn.Login(user, pass);

        if (kq == 2 || kq == 3)
        {
            tbUserName.ErrorText = "Không hợp lệ";
            tbUserName.IsValid   = false;
        }
        else
        {
            if (string.IsNullOrEmpty(Request.QueryString["ReturnUrl"]))
            {
                FormsAuthentication.SetAuthCookie(tbUserName.Text, false);
                Response.Redirect("~/Content/DanhSachTour.aspx?user=" + tbUserName.Text);
            }
            else
            {
                FormsAuthentication.RedirectFromLoginPage(tbUserName.Text, false);
            }
        }
    }
        protected void btn_submit_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string salt = vu.RetrieveSalt(tb_username.Text);
                if (salt.Equals("-1"))
                {
                    alert_placeholder.Visible             = true;
                    alert_placeholder.Attributes["class"] = "alert alert-danger alert-dismissable";
                    alertText.Text = "Username or password is incorrect.";
                }
                else
                {
                    if (vu.AuthenticateUser(tb_username.Text, tb_password.Text, salt))
                    {
                        // Perform a redirect to Home page
                        Session["username"]  = tb_username.Text;
                        Session["accountID"] = vu.GetAccountID(tb_username.Text, tb_password.Text, salt);
                        Session["role"]      = vu.getRoleByAccID(Session["accountID"].ToString());
                        FormsAuthentication.RedirectFromLoginPage(tb_username.Text, true);
                        //Response.Write(Session["role"]);
                        //Response.Write(Session["role"].GetType());


                        //alert_placeholder.Visible = true;
                        //alert_placeholder.Attributes["class"] = "alert alert-success alert-dismissable";
                        //alertText.Text = "Login successful! Account ID is " + Session["accountID"].ToString();
                    }
                    else
                    {
                        alert_placeholder.Visible             = true;
                        alert_placeholder.Attributes["class"] = "alert alert-danger alert-dismissable";
                        alertText.Text = "Username or password is incorrect.";
                    }
                }
            }
        }
Пример #11
0
        public ActionResult SignIn(Login login, string returnUrl = "")
        {
            var usuariovalido = false;
            var msj           = string.Empty;

            if (!ModelState.IsValid)
            {
                return(View());
            }

            usuariovalido = Membership.ValidateUser(login.correo, login.password);

            if (Session["mensaje_validateuser"] != null)
            {
                msj = Convert.ToString(Session["mensaje_validateuser"]);
            }

            if (string.IsNullOrEmpty(msj) == false)
            {
                ViewBag.Mensaje = msj;
            }

            if (usuariovalido)
            {
                var usuario = (CustomMembershipUser)Membership.GetUser(login.correo);
                if (usuario != null && Session["mensaje_validateuser"] == null)
                {
                    FormsAuthentication.RedirectFromLoginPage(usuario.NombreUsuario, false);
                }
                else
                {
                    ModelState.AddModelError("", Convert.ToString(Session["mensaje_validateuser"]));
                }
            }

            return(View(login));
        }
Пример #12
0
        protected void btnLogar_Click(object sender, EventArgs e)
        {
            string          connectionString   = "datasource=localhost;port=3306;username=root;password=s3t3mbr0;database=mobilidade;";
            MySqlConnection databaseConnection = new MySqlConnection(connectionString);

            databaseConnection.Open();
            user     = this.txtLogin.Text;
            password = this.txtSenha.Text;
            string       query   = "select * from usuario where usuario.login = @Login and usuario.senha = @Senha;";
            MySqlCommand command = new MySqlCommand(query, databaseConnection);

            command.Parameters.Add("@Login", MySqlDbType.VarChar).Value = user;
            command.Parameters.Add("@Senha", MySqlDbType.VarChar).Value = password;
            MySqlDataReader reader = command.ExecuteReader();

            //MySqlDataReader reader2 = command2.ExecuteReader();
            // lblDebug.Text = rea
            //lblDebug.Text = reader.HasRows.ToString();
            if (reader.HasRows)
            {
                if (reader.Read())
                {
                    Session["Salvarid"]    = reader.GetUInt32(0);
                    Session["Salvarnome"]  = reader.GetString("login");
                    Session["Salvarsenha"] = reader.GetString("senha");
                    Session["tpusu"]       = reader.GetUInt16("UsuAdm");
                }
                FormsAuthentication.RedirectFromLoginPage(user, false);
                //Response.Redirect("Default.aspx",);
                //Response.Redirect("/Paginas/ConsultaVeiculos.aspx");
            }
            else
            {
                lblDebug.Text = "Login ou senha invalido!";
                // FormsAuthentication.RedirectToLoginPage();
            }
        }
Пример #13
0
 public ActionResult Login(Employee employee)
 {
     _Logger.Info("An Employee tried to Log in With ID " + employee.Employee_Id.ToString());
     try
     {
         using (var Client = new HttpClient())
         {
             Client.BaseAddress = new Uri(GlobalHelpers.WebAPIURL);
             Client.DefaultRequestHeaders.Add("API_KEY", ConfigurationManager.AppSettings["APIKey"].ToString());
             var Response = Client.PostAsJsonAsync(GlobalHelpers.ValidateEmployee, employee).Result;
             if (Response.IsSuccessStatusCode)
             {
                 _Logger.Info("Login Successful");
                 FormsAuthentication.RedirectFromLoginPage(employee.Employee_Id.ToString(), false);
                 Session["Security"]     = employee.Employee_Id;
                 Session["Organisation"] = employee.OrganisationId;
                 return(RedirectToAction("Index", "Employee", new { id = employee.Employee_Id, organisationID = employee.OrganisationId }));
             }
             else
             {
                 _Logger.Info("Login Failed");
                 FormsAuthentication.SignOut();
                 return(View());
             }
         }
     }
     catch (MySqlException ex)
     {
         _Logger.Error("Login Failed" + ex.ToString());
         return(RedirectToAction("DatabaseError", "Home"));
     }
     catch (Exception ex)
     {
         _Logger.Fatal("Login Failed" + ex.ToString());
         return(RedirectToAction("ERROR404", "Home"));
     }
 }
        public bool ValidateOpenIDUser()
        {
            try
            {
                var response = consumer.GetResponse();
                if (response.Status != AuthenticationStatus.Authenticated)
                {
                    return(false);
                }

                _sreg = response.GetExtension <ClaimsResponse>();

                MembershipUser user = GetUserByOpenId(response.ClaimedIdentifier, true);
                if (user != null)
                {
                    FormsAuthentication.RedirectFromLoginPage(user.UserName, false);
                    return(true); // never reached, due to redirect
                }
                else
                {
                    throw new OpenIdNotLinkedException(response.ClaimedIdentifier);
                }
            }
            catch (ProtocolException ex)
            {
                if (WriteExceptionsToEventLog)
                {
                    Utility.WriteToEventLog(ex, "ValidateOpenIDUser");
                }

                return(false);
            }
            catch (OpenIdNotLinkedException nlEx)
            {
                throw nlEx;
            }
        }
Пример #15
0
    protected void ValidateUser(object sender, EventArgs e)
    {
        EmployeeProfile emp = (EmployeeProfile)Session["EmployeeProfile"];

        if (!string.Equals(emp.Name, Login1.UserName))
        {
            emp.Name = Login1.UserName;
        }
        if (!string.Equals(emp.Password, Login1.Password))
        {
            emp.Password = Login1.Password;
        }
        TextBox TextBox1 = (TextBox)Login1.FindControl("Machine");

        if (null != TextBox1)
        {
            emp.Machine = TextBox1.Text;
        }

        //Login1.FailureText = "Account has not been activated.";
        if (string.IsNullOrEmpty(emp.Name))
        {
            Login1.FailureText = "Username and/or password is incorrect.";
        }
        else
        {
            try {
                Session["EventLogReader"] = createEventQuery(emp);
                FormsAuthentication.RedirectFromLoginPage(
                    String.Format("{0}@{1}", Login1.UserName, emp.Machine),
                    Login1.RememberMeSet);
            }
            catch (UnauthorizedAccessException err) {
                Login1.FailureText = String.Format("{0} on {1}",
                                                   err.Message, emp.Machine);
            }
        }
Пример #16
0
        protected void LoginUser(object sender, EventArgs e)
        {
            var query = Query.And(Query <User> .EQ(u => u.Username, txtUsername.Text), Query <User> .EQ(u => u.Password, txtPassword.Text));
            MongoCursor <User> cursor = users.Find(query);
            var list = cursor.ToList();

            if (list.Count != 0)
            {
                Session["userType"] = list[0].Type;
                FormsAuthentication.RedirectFromLoginPage(txtUsername.Text, false);
            }
            else
            {
                Response.Write("<script language = javascript> alert('Login Unsuccessful');</script >");
            }
            //foreach (User item in cursor.)
            //{
            //    if (txtUsername.Text == item.Username && txtPassword.Text == item.Password)
            //    {


            //    }
            //}
        }
Пример #17
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        lblUsername.Visible  = false;
        lblPassword.Visible  = false;
        lblMainError.Visible = false;

        if (txtPassword.Text != "" && txtUsername.Text != "")
        {
            if (AuthenticateUser(txtUsername.Text, txtPassword.Text))
            {
                FormsAuthentication.RedirectFromLoginPage(txtUsername.Text, CheckBox1.Checked);
            }
            else
            {
                lblMainError.Visible = true;
                lblMainError.Text    = "Invalid User Name and /or Password";
            }
        }
        else if (txtPassword.Text == "" && txtUsername.Text == "")
        {
            lblUsername.Visible = true;
            lblUsername.Text    = "User Name Required";
            lblPassword.Visible = true;
            lblPassword.Text    = "Password Required";
        }
        else if (txtPassword.Text == "")
        {
            lblPassword.Visible = true;
            lblPassword.Text    = "Password Required";
        }
        else if (txtUsername.Text == "")
        {
            lblUsername.Visible = true;
            lblUsername.Text    = "User Name Required";
        }
    }
Пример #18
0
 protected void btnSignin_Click(object sender, EventArgs e)
 {
     try
     {
         int     IdRole = 0;
         DataSet d1     = obj.GetLogin(txtUserName.Text, txtPwd.Text);
         string  id     = d1.Tables[0].Rows[0][0].ToString();
         IdRole = Convert.ToInt32(id);
         if (IdRole >= 0)
         {
             lblError.Text = "valid user";
             string time      = System.DateTime.Today.ToShortDateString();
             string loginuser = txtUserName.Text;
             Session["Username"] = txtUserName.Text;
             obj.logintime(loginuser, time);
             FormsAuthentication.RedirectFromLoginPage(txtUserName.Text.Trim(), false);
             if (IdRole == 8)
             {
                 Response.Redirect("~/Admin/frmAdmin.aspx");
             }
             else
             {
                 Response.Redirect("~/MyAccount/frmMyAccount.aspx?u=" + Session["Username"]);
             }
         }
         else
         {
             // lblError.Text = "not a valid user";
             Response.Write("<script>alert('Invalid User Name/Password')</script>");
         }
     }
     catch (Exception ex)
     {
         Response.Write(ex.Message);
     }
 }
        public ActionResult GirisYap(Kullanici k, string Hatirla)
        {
            bool sonuc = Membership.ValidateUser(k.UserName, k.Password);

            if (sonuc)
            {
                // Bunu çalışması için web.config de bazı ayarların düzenlenmesi gerekir. Yani bu web sitesine üye giriş yapılabileceğine dair ayar yapmamız lazım
                if (Hatirla == "on")
                {
                    FormsAuthentication.RedirectFromLoginPage(k.UserName, true);
                }
                else
                {
                    FormsAuthentication.RedirectFromLoginPage(k.UserName, false);
                }

                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ViewBag.Mesaj = "Kullanıcı adı veya parola hatalı!";
                return(View());
            }
        }
Пример #20
0
        protected void BtnLogin_Click(object sender, EventArgs e)
        {
            var repo = new Repository();

            if (repo.IsCorrectUser(TxtUserID.Text, TxtPaswword.Text))
            {
                //성공 인증부여
                if (!string.IsNullOrEmpty(Request["ReturnUrl"]))
                {
                    FormsAuthentication.RedirectFromLoginPage(TxtUserID.Text, false);
                }
                else
                {
                    FormsAuthentication.SetAuthCookie(TxtUserID.Text, false);//인증된 사용자 아이디를 쿠키
                    Response.Redirect("~/Welcome.aspx");
                }
            }
            else
            {
                //실패
                Response.Write("<script>alert('잘못된 사용자입니다!');</script>");
                Response.End();
            }
        }
Пример #21
0
        protected void ButtonLoginOk_Click(object sender, EventArgs e)
        {
            AccountManager accountManager = new AccountManager(ConfigurationManager.ConnectionStrings["XiahDb"].ConnectionString,
                                                               ConfigurationManager.ConnectionStrings["XiahDb"].ProviderName);

            TextBox UsernameTextBox            = LoginView.FindControl("UsernameTextBox") as TextBox;
            TextBox PasswordTextBox            = LoginView.FindControl("PasswordTextBox") as TextBox;
            Label   WrongUsernamePasswordLabel = LoginView.FindControl("WrongUsernamePasswordLabel") as Label;

            if (Page.IsValid)
            {
                int userId = accountManager.GetUserIdByUsernameAndPassword(UsernameTextBox.Text, PasswordTextBox.Text);

                if (userId < 1)
                {
                    WrongUsernamePasswordLabel.Text = "Wrong username or password.";
                }
                else
                {
                    Session["UserId"] = userId;
                    FormsAuthentication.RedirectFromLoginPage(UsernameTextBox.Text, false);
                }
            }
        }
Пример #22
0
 /// <summary>
 /// Runs when the user clicks on the login button. It first checks that the user's credentials are in the database,
 /// then sees if they're still using a default password.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void OnLogIn(object sender, EventArgs e)
 {
     if (LoginHelper.ValidateLogin(Nom.Text, Password.Text))
     {
         // Login was successful but need to check for unchanged password
         if (NeedsNewPassword(Nom.Text, Password.Text))
         {
             Name.Text                   = Nom.Text;
             Connect.Visible             = false;
             ChangePasswordPanel.Visible = true;
             labOutput.Text              = "Vous utilisez encore le mot de passe d'origine. Pour plus de sécurité, veuillez changer ce mot de passe ci-dessous.";
         }
         else
         {
             labOutput.Text = "Connexion avec succès";
             FormsAuthentication.RedirectFromLoginPage(Nom.Text, false);
         }
     }
     else
     {
         // Login failed
         labOutput.Text = "La connexion a échoué. Veuillez vérifier votre nom d'utilisateur et votre mot de passe.";
     }
 }
Пример #23
0
        protected void LoginBtn_Click(object sender, EventArgs e)
        {
            BLL    customer = new BLL();
            string username = TxtBoxUserName.Text.Trim();
            string password = Encrypter.EncryptText(TxtBoxPsswrd.Text.Trim());

            customer.CustName = username;
            customer.Password = password;

            //check if user exists in the table then login the user
            if (bll.AuthenticateUser(customer))
            {
                labelOutput.Text      = "Login Done!";
                labelOutput.ForeColor = System.Drawing.Color.Green;


                FormsAuthentication.RedirectFromLoginPage(username, false);
            }
            else
            {
                labelOutput.Text      = "Login failed. Please try again.";
                labelOutput.ForeColor = System.Drawing.Color.Red;
            }
        }
Пример #24
0
 protected void LoginButton_Click(object sender, EventArgs e)
 {
     try
     {
         //koetetaan autentikoitua käyttämällä AutentikointiDB luokkaa
         // lisataan config.webistä
         AutentikointiDB.ConnectionString = ConfigurationManager.ConnectionStrings["BookShop"].ConnectionString;
         if (AutentikointiDB.Login(LoginUser.UserName, LoginUser.Password))
         {
             lblNotes.Text = Page.User.ToString();
             FormsAuthentication.RedirectFromLoginPage(LoginUser.UserName, false);
         }
         else
         {
             lblNotes.Text = "Autentikointi epäonnistui";
         }
     }
     catch (Exception ex)
     {
         lblNotes.Text = ex.Message; // HUOM! ei lopullinen, vaan koodarin testauksen ajan.
         //lblNotes.Text = "Autentikointipalvelua ei voi käyttää, yritä hetken päästä uudestaan.";
         //throw;
     }
 }
Пример #25
0
    public ActionResult Login(LoginModel model, string returnUrl)
    {
        if (!this.ModelState.IsValid)
        {
            return(this.View(model));
        }

        if (Membership.ValidateUser(model.UserName, model.Password))
        {
            FormsAuthentication.RedirectFromLoginPage(model.UserName, model.RememberMe);
            FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
            if (this.Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
            {
                return(this.Redirect(returnUrl));
            }

            return(this.RedirectToAction("TFSProjects", "TestSuite"));
        }

        this.ModelState.AddModelError(string.Empty, "The user name or password provided is incorrect.");

        return(this.View(model));
    }
Пример #26
0
        public ActionResult GirisYap(Kullanici kl)
        {
            string ka = ValidateUser(kl.KullaniciAdi, kl.Parola);

            if (!string.IsNullOrEmpty(ka))
            {
                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
                                                                                 kl.KullaniciAdi,
                                                                                 DateTime.Now,
                                                                                 DateTime.Now.AddMinutes(15),
                                                                                 true, ka, FormsAuthentication.FormsCookiePath);

                HttpCookie ck = new HttpCookie
                                    (FormsAuthentication.FormsCookieName);
                if (ticket.IsPersistent)
                {
                    ck.Expires = ticket.Expiration;
                }
                Response.Cookies.Add(ck);

                FormsAuthentication.RedirectFromLoginPage(kl.KullaniciAdi, true);
            }
            return(RedirectToAction("GirisYap"));
        }
Пример #27
0
 protected void lgnLogin_LoggedIn(object sender, EventArgs e)
 {
     try
     {
         Login loLogin = (Login)sender;
         Response.Cookies.Add(new HttpCookie(
                                  FormsAuthentication.FormsCookieName,
                                  FormsAuthentication.Encrypt(new FormsAuthenticationTicket(1,
                                                                                            HttpContext.Current.Session.SessionID,
                                                                                            DateTime.Now,
                                                                                            DateTime.Now.AddMinutes(FormsAuthentication.Timeout.TotalMinutes),
                                                                                            false, loLogin.UserName,
                                                                                            FormsAuthentication.FormsCookiePath
                                                                                            )))
         {
             Secure = true
         });
         FormsAuthentication.RedirectFromLoginPage(loLogin.UserName, false);
     }
     catch (Exception)
     {
         ((Login)sender).FailureText = "Credenciales no v&aacute;lidas. Intenta nuevamente por favor";
     }
 }
Пример #28
0
        protected void OpenIdLogin_Click(object sender, CommandEventArgs e)
        {
            #region Disable OpenID
            //try
            //{
            //    using (OpenIdRelyingParty openid = new OpenIdRelyingParty())
            //    {
            //        IAuthenticationRequest request = openid.CreateRequest(e.CommandArgument.ToString());

            //        // This is where you would add any OpenID extensions you wanted
            //        // to include in the authentication request.
            //        request.AddExtension(new ClaimsRequest
            //        {
            //            Email = DemandLevel.Require,
            //            FullName = DemandLevel.Require,
            //            Nickname = DemandLevel.Require,
            //            Country = DemandLevel.Require,
            //            Gender = DemandLevel.Require
            //        });

            //        // Send your visitor to their Provider for authentication.
            //        request.RedirectToProvider();
            //    }
            //}
            //catch (ProtocolException ex)
            //{
            //    // The user probably entered an Identifier that
            //    // was not a valid OpenID endpoint.
            //    //this.openidValidator.Text = ex.Message;
            //    //this.openidValidator.IsValid = false;
            //}
            Utility.CurrentSession.Instance.LoginEmail        = "*****@*****.**";
            Utility.CurrentSession.Instance.FriendlyLoginName = "Guest";
            FormsAuthentication.RedirectFromLoginPage("Guest", false);
            #endregion
        }
Пример #29
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string user = user_name.Value;
            string pass = user_pass.Value;

            try
            {
                if (!user.Equals(null) && !pass.Equals(null))
                {
                    USUARIO_BE u = USUARIO_BLL.GET(user);
                    //u.ID = "admin";
                    //u.PASS = "******";
                    accionesUsuario aU = new accionesUsuario();
                    if (aU.existeUsuario(u, user, pass))
                        FormsAuthentication.RedirectFromLoginPage(user, true);
                    else
                        lblError.Text = idioma.user_error;
                }
            }
            catch
            {
                lblError.Text = "";
            }
        }
Пример #30
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            var userRepo = new UserRepository();

            if (userRepo.IsCorrectUser(txtUserID.Text, txtPassword.Text))
            {
                //[!]인증 부여
                if (!String.IsNullOrEmpty(Request.QueryString["ReturnUrl"]))
                {
                    //인증과 동시에 팅겨져 나온 페이지로 이동
                    FormsAuthentication.RedirectFromLoginPage(txtUserID.Text, false);
                }
                else
                {
                    //인증 쿠키값 부여
                    FormsAuthentication.SetAuthCookie(txtUserID.Text, false);
                    Response.Redirect("~/Welcome.aspx");
                }
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "showMsg", "<script>alert('잘못된 사용자 입니다.');</script>");
            }
        }