Exemplo n.º 1
0
        public IActionResult Index()
        {
            LoginDB Usuario = new LoginDB();
            var     MLista  = Usuario.GetAll();

            return(View(MLista));
        }
        public int updatePassword(Login login)
        {
            int count = LoginDB.updatePassword(login);

            DBUtil.DBUtil.closeSqlConnection();
            return(count);
        }
Exemplo n.º 3
0
        private void Save()
        {
            try
            {
                if (!ValidateControls())
                {
                    return;
                }

                Login login = new Login();
                login.USER_ID      = txtUserID.Text;
                login.PASSWORD_ID  = txtPassword.Text;
                login.X_FIRST_LOG  = chkFirstLog.Checked == true ? "X" : null;
                login.X_TEMPLATE   = chkTemplate.Checked == true ? "X" : null;
                login.DATE_EXPIRED = DateTime.Now.AddDays(90);
                login.NAME         = txtName.Text;
                login.SURNAME      = txtSurname.Text;

                LoginDB.SaveNewLogin(login);

                MessageBox.Show("La nuova utenza è stata correttamente registrata.", "Nuovo Account", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Non è stato possibile registrare correttamente la nuova utenza: " + ex.Message);
            }
        }
        public List <Login> getAllLogin()
        {
            List <Login> list = LoginDB.getAll();

            DBUtil.DBUtil.closeSqlConnection();
            return(list);
        }
        private static void OpenForm(LoginDB Info)
        {
            switch (Info.FormToOpen)
            {
            case Klant_main klant:
                Klant_main k = new Klant_main();
                k.Show();
                break;

            case Chauffeurs chaufeur:
                Chauffeurs c = new Chauffeurs();
                c.Show();
                break;

            case Planners planner:
                Planners p = new Planners();
                p.Show();
                break;

            case Managers manager:
                Managers m = new Managers();
                m.Show();
                break;
            }
        }
        public int addLogin(Login login)
        {
            int count = LoginDB.add(login);

            DBUtil.DBUtil.closeSqlConnection();
            return(count);
        }
Exemplo n.º 7
0
        public ActionResult Index (LoginModel dados)
        {
            LoginDB dbLogin = new LoginDB ();

            if (ModelState.IsValid)
            {
                UsersModel utilizador = dbLogin.validateLogin (dados);
                if (utilizador == null)
                {
                    ModelState.AddModelError ("", "Login Failed");
                    return View (dados);
                }
                else
                {
                    Session["usertype"] = utilizador.usertype;
                    Session["username"] = utilizador.username;
                    Session["userid"] = utilizador.id;
                    FormsAuthentication.SetAuthCookie (utilizador.username, false);

                    if (Request.QueryString["ReturnUrl"] == null)
                        return RedirectToAction ("Index", "Home");
                    else
                        return Redirect (Request.QueryString["ReturnUrl"].ToString ());
                }
            }
            return View (dados);
        }
Exemplo n.º 8
0
        public IActionResult Cliente()
        {
            LoginDB Cliente = new LoginDB();
            var     MLista  = Cliente.GetAllCliente();

            return(View(MLista));
        }
Exemplo n.º 9
0
        public LoginResponse SignIn(LoginRequest model)
        {
            var command = string.Format("select * from users where nome = '{0}' and senha = '{1}'", model.User, model.Password);
            var login   = LoginDB.GetLogin(command, model.UserId, model.PasswordBD, model.Url);

            return(login);
        }
 public AdminLogin()
 {
     InitializeComponent();
     this.db = new LoginDB();
     this.txt_UserName.Focus();
     this.MouseDown += WindowMouseDown;
 }
Exemplo n.º 11
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            //Validate if has value
            if (txtUserName.Text != "" && txtPassword.Text != "")
            {
                //Gets custID for username
                int?custIDNull = LoginDB.authenticateUser(txtUserName.Text);

                if (custIDNull != null)//If username exists auth password
                {
                    int custID = (int)custIDNull;
                    if (LoginDB.authenticatePassword(custID, txtPassword.Text))
                    {
                        Session["CustID"] = custID;
                        Response.Redirect("index.aspx");
                    }
                    else
                    {
                        lblStatus.Text     = "Invalid password.";
                        lblStatus.CssClass = "alert alert-warning";
                    }
                }
                else
                {
                    lblStatus.Text     = "Invalid username";
                    lblStatus.CssClass = "alert alert-warning";
                }
            }
            else
            {
                lblStatus.Text     = "Please enter a username and password";
                lblStatus.CssClass = "alert alert-primary";
            }
        }
        private void Save()
        {
            try
            {
                if (!ValidateControls(false))
                {
                    return;
                }

                var login = LoginDB.LoadLogin(sUserId, string.Empty);
                if (login == null)
                {
                    throw new Exception("Utente non riconosciuto.");
                }

                LoginDB.SaveLogin(login.KEY_LOG, txtPassword.Text, null);

                MessageBox.Show("La password è stata correttamente aggiornata.", "Reset Password", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                recoveryPassword = true;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Non è stato possibile aggiornare la password: " + ex.Message);
            }
        }
Exemplo n.º 13
0
        public IActionResult Funcionario()
        {
            LoginDB Funcionario = new LoginDB();
            var     MLista      = Funcionario.GetAllFuncionario();

            return(View(MLista));
        }
Exemplo n.º 14
0
        public override void OnAuthorization(HttpActionContext actionContext)
        {
            //ilk önce oturum kontrolu yapılacak
            if (actionContext.Request.Headers.Authorization == null)
            {
                actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized);
            }
            else
            {
                // Oturum var ise kullanıcı Email ve şifresini alacagız
                var     tokenKey         = actionContext.Request.Headers.Authorization.Parameter;
                var     userNamePassword = Encoding.UTF8.GetString(Convert.FromBase64String(tokenKey));
                var     userInfoArray    = userNamePassword.Split(':');
                var     Email            = userInfoArray[0];
                var     Sifre            = userInfoArray[1];
                LoginDB login            = new LoginDB();

                if (login.KullaniciEmailVeSifre(Email, Sifre).Count > 0)
                {
                    Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity(Email), null);
                }
                else
                {
                    actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized);
                }
            }
        }
 public AdminLogin(string login)
 {
     InitializeComponent();
     this.db = new LoginDB();
     this.txt_UserName.Focus();
     this.parentTools = true;
     this.MouseDown  += WindowMouseDown;
 }
Exemplo n.º 16
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            LoginDB l      = new LoginDB(TextBox1.Text, TextBox2.Text);
            var     result = l.Autenticar();



            Label1.Text = result.ToString();
        }
 public ParentIDEntry(bool editP)
 {
     InitializeComponent();
     editParent = editP;
     this.db    = new LoginDB();
     this.txt_IDEntry.KeyDown += new KeyEventHandler(KeyPressedValidateNumber);
     this.txt_IDEntry.Focus();
     this.MouseDown += WindowMouseDown;
     txt_IDEntry.Focus();
 }
Exemplo n.º 18
0
 //Add the Form Related to a Table For rolplay based
 private static void OpenForm(LoginDB Info)
 {
     switch (Info.WinodowToOpen)
     {
     case MainView main:
         MainView k = new MainView();
         k.Show();
         break;
     }
 }
        private bool ValidateControls(bool onlyCode)
        {
            bool res = true;

            errorProvider1.Clear();
            if (string.IsNullOrEmpty(txtCode.Text))
            {
                errorProvider1.SetError(txtCode, "Inserire il codice ricevuto via mail.");
                txtCode.Focus();
                res = false;
            }
            if (sCode != txtCode.Text)
            {
                errorProvider1.SetError(txtCode, "Il codice inserito non è valido.");
                txtCode.Focus();
                res = false;
            }
            if (onlyCode)
            {
                return(res);
            }
            if (string.IsNullOrEmpty(txtPassword.Text))
            {
                errorProvider1.SetError(txtPassword, "Inserire una password valida.");
                txtPassword.Focus();
                res = false;
            }
            if (string.IsNullOrEmpty(txtConfirmPass.Text))
            {
                errorProvider1.SetError(txtConfirmPass, "Confermare la password.");
                txtConfirmPass.Focus();
                res = false;
            }
            if (txtPassword.Text != txtConfirmPass.Text)
            {
                errorProvider1.SetError(txtConfirmPass, "Le due password non coincidono.");
                txtConfirmPass.Focus();
                res = false;
            }
            var txtPass = LoginDB.LoadLogin(sUserId, null).PASSWORD_ID;

            if (txtPass == LoginDB.ToSha256(txtPassword.Text))
            {
                errorProvider1.SetError(txtPassword, "Inserire una password differente rispetto all'ultima.");
                txtPassword.Focus();
                res = false;
            }
            if (!IsCorrectPassword(txtPassword.Text))
            {
                errorProvider1.SetError(txtPassword, "Violazione delle regole. La password deve contenere: una lettera maiuscola, una minuscola, un numero, un carattere speciale.");
                txtPassword.Focus();
                return(false);
            }
            return(res);
        }
Exemplo n.º 20
0
    protected void btnSalvar_Click(object sender, EventArgs e)
    {
        Funcionario fun = new Funcionario();

        if (txbSenha.Text == txbNova.Text)
        {
            if (ValidarSenha(txbSenha.Text))
            {
                FunMod fmp = new FunMod();
                if (fmp != null)
                {
                    fmp.Funcionario         = fun;
                    fmp.Funcionario.Fun_cod = n;
                    fmp.AlteraSenha(txbNova.Text);
                    fmp.Funcionario.Cod_fun = n;

                    switch (FuncionarioDB.AlterarSenha(fmp))
                    {
                    case 0:
                        fmp = LoginDB.Sessão(n);
                        if (fmp.Funcionario.Pessoa.Pes_ativo == "Ativo" && fmp.Funcionario.Fun_primeiroAcesso == false)
                        {
                            //testa a validade do parametro da sessão
                            Session.Add("teste", "first");
                            Session.Add("Funcionario", fmp);
                            Session.Add("info", "mensagem");
                            if (fmp.Funcionario.Perfil.Pfl_descricao.Equals("Administrador"))
                            {
                                Response.Redirect("~/paginas/Admin.aspx");
                            }
                            else
                            {
                                Response.Redirect("~/paginas/Index.aspx");
                            }
                        }
                        break;

                    case -2:
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>error();</script>", false);
                        break;
                    }
                }
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>warning1();</script>", false);
            }
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>warning();</script>", false);
        }
    }
Exemplo n.º 21
0
        public void InserirTest()
        {
            LoginDB l = new LoginDB();

            l.Login = "******";
            l.Senha = "123";
            l.Save();

            var result = LoginDB.Get(l.ID);

            Assert.AreEqual("binhara", result.Login);
            Assert.AreEqual("123", result.Senha);
        }
Exemplo n.º 22
0
        private void button1_Click(object sender, EventArgs e)
        {
            int    us_id       = 0;
            String usuario     = textBox1.Text;
            String contrasenia = textBox2.Text;

            us_id = LoginDB.login(usuario, contrasenia);
            if (us_id >= 0)
            {
                Hide();
                Elegir_Rol.Elegir_Rol form = new Elegir_Rol.Elegir_Rol(us_id);
                form.Show();
            }
        }
Exemplo n.º 23
0
        public string Validar(tb_login obj)
        {
            LoginDB Usuario = new LoginDB();

            if (String.IsNullOrEmpty(obj.Tipo))
            {
                return("<div class='alert alert-warning text-center' role='alert'>Digite o tipo</div>");
            }
            if (Usuario.Validalogin(obj))
            {
                return("<div class='alert alert-warning text-center' role='alert'>Nome já existente!</div>");
            }
            return("");
        }
 public GuardianCheckIn()
 {
     InitializeComponent();
     this.WindowState                   = WindowState.Maximized;
     this.db                            = new LoginDB();
     this.txt_IDEntry.KeyDown          += new KeyEventHandler(KeyPressedValidateNumber);
     this.txt_PINEntry.KeyDown         += new KeyEventHandler(KeyPressedValidateNumber);
     this.txt_IDEntry.GotFocus         += OnBoxFocus;
     this.txt_PINEntry.GotFocus        += OnBoxFocus;
     this.txt_IDEntry.GotMouseCapture  += new System.Windows.Input.MouseEventHandler(OnBoxFocus);
     this.txt_PINEntry.GotMouseCapture += new System.Windows.Input.MouseEventHandler(OnBoxFocus);
     this.txt_IDEntry.Focus();
     this.MouseDown += WindowMouseDown;
 }
Exemplo n.º 25
0
        public bool GetKullaniciGirisi(string email, string sifre)
        {
            LoginDB loginDB = new LoginDB();

            if (loginDB.GetKullaniciGiris(email, sifre))
            {
                HttpContext.Current.Response.Redirect("~/BitkiDetay.aspx");
            }
            else
            {
                HttpContext.Current.Response.Redirect("~/Login.aspx");
            }
            return(false);
        }
Exemplo n.º 26
0
        private bool ValidateControls()
        {
            errorProvider1.Clear();
            if (string.IsNullOrEmpty(txtUserID.Text))
            {
                errorProvider1.SetError(txtUserID, "Inserire un user Id valido.");
                txtUserID.Focus();
                return(false);
            }
            var login = LoginDB.LoadLogin(txtUserID.Text, string.Empty);

            if (login.KEY_LOG.HasValue)
            {
                errorProvider1.SetError(txtUserID, "Esiste già un accounto con lo stesso user ID.");
                txtUserID.Focus();
                return(false);
            }
            if (string.IsNullOrEmpty(txtName.Text))
            {
                errorProvider1.SetError(txtName, "Inserire il nome.");
                txtName.Focus();
                return(false);
            }
            if (string.IsNullOrEmpty(txtSurname.Text))
            {
                errorProvider1.SetError(txtSurname, "Inserire il cognome.");
                txtSurname.Focus();
                return(false);
            }
            if (string.IsNullOrEmpty(txtPassword.Text))
            {
                errorProvider1.SetError(txtPassword, "Inserire la password.");
                txtPassword.Focus();
                return(false);
            }
            if (string.IsNullOrEmpty(txtConfirmPass.Text))
            {
                errorProvider1.SetError(txtConfirmPass, "Confermare la password.");
                txtConfirmPass.Focus();
                return(false);
            }
            if (txtPassword.Text != txtConfirmPass.Text)
            {
                errorProvider1.SetError(txtConfirmPass, "Le due password non coincidono.");
                txtConfirmPass.Focus();
                return(false);
            }
            return(true);
        }
Exemplo n.º 27
0
    protected void btnLogar_Click(object sender, EventArgs e)
    {
        Funcionario fun = LoginDB.SelectLogin(new FuncionarioCrypto()
        {
            Fun_matricula = txbMatricula.Text,
            Fun_senha     = txbSenha.Text
        });

        //Funcionario fun = LoginDB.SelectLogin(txbMatricula.Text, txbSenha.Text);

        //parte de sessões
        if (fun != null)
        {
            FunMod fmp = LoginDB.Sessão(fun.Fun_cod);
            if (fmp.Funcionario.Pessoa.Pes_ativo == "Ativo" && fmp.Funcionario.Fun_primeiroAcesso == false)
            {
                //testa a validade do parametro da sessão
                Session.Add("teste", "first");
                Session.Add("Funcionario", fmp);
                Session.Add("info", "mensagem");
                if (fmp.Funcionario.Perfil.Pfl_descricao.Equals("Administrador"))
                {
                    Response.Redirect("~/paginas/Admin.aspx");
                }
                else
                {
                    Response.Redirect("~/paginas/Index.aspx");
                }
                //Response.Redirect("~/TesteSession.aspx");
            }
            else
            {
                if (fmp.Funcionario.Pessoa.Pes_ativo != "Ativo")
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>error();</script>", false);
                }
                if (fmp.Funcionario.Fun_primeiroAcesso != false)
                {
                    Response.Redirect("~/paginas/AlterarSenha.aspx?par=" + Funcoes.AESCodifica(Convert.ToString(fun.Fun_cod)));
                }
            }
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>warning();</script>", false);
        }
    }
Exemplo n.º 28
0
        private void button1_Click(object sender, EventArgs e)
        {
            string  username = txtTaiKhoan.Text;
            string  password = txtMatKhauMoi.Text;
            LoginDB db       = new LoginDB();

            try
            {
                if (db.ChangePassword(username, password))
                {
                    MessageBox.Show("Thay doi thanh cong");
                }
            }catch (Exception ex)
            {
                MessageBox.Show("Thay doi mat khau that bai");
            }
        }
Exemplo n.º 29
0
        public void GetSifremiUnuttumMailGonderBy(string email)
        {
            //Yapılacaklar
            //1. kontrol email var mı ona bakılacak
            //2. varsa mail atılacak kişiye

            var kullanici = new KullaniciBilgileriEn()
            {
                Email = email,
            };

            LoginDB login = new LoginDB();

            if (login.GetSifremiUnuttumBy(kullanici.Email) == false)
            {
                MailSendTO ayarlar = new MailSendTO();
                ayarlar.MailAyarlari();

                MailMessage mailMessage = new MailMessage();
                mailMessage.From = new MailAddress(kullanici.Email);
                mailMessage.To.Add(kullanici.Email);

                //TODO list deki degerleri nasıl alabilirim degişkenlerin yerine yazdım Bu mantık dogrumu?

                string ad    = "";
                string soyad = "";
                string sifre = "";
                foreach (var bilgi in login.GetKullaniciKaydiBilgileri(kullanici.Email))
                {
                    ad    = bilgi.Ad;
                    soyad = bilgi.Soyad;
                    sifre = bilgi.Sifre;
                }
                string SifreOnay = Guid.NewGuid().ToString("N").Substring(0, 6);
                mailMessage.Subject = "Bitkimi Tanı'dan Kullanıcı Şifrenizi Hatırlatma";
                mailMessage.Body    = "Merhaba,<br/>Lütfen giriş bilgilerinizi kontrol ediniz.<br/> Kullanıcı Adınız:" + ad + "" + " " + " " + soyad + "<br/><br/>Şifreniz :" + SifreOnay + "";

                //Veri tabanına kaydediyorum burda sifreyi
                login.MailSifreOnayKoduOlustur(SifreOnay, kullanici.Email);

                // throw new Exception("Mail Gönderme işlemi sırasında hata oluştu"); //Hata fırlatma işi dogru mu?
                Hata hata       = new Hata();
                var  hataOlustu = hata.ToString();//Hatayı bu şekilde yakalama şansım nedir? varsa veri tabanına kaydetcem :))
            }
        }
Exemplo n.º 30
0
        private void pictureBox2_MouseHover(object sender, EventArgs e)
        {
            var loginAccess = LoginDB.LoadLoginAccess();

            if (loginAccess == null)
            {
                return;
            }

            if (!loginAccess.KEY_LOG.HasValue)
            {
                return;
            }

            ToolTip toolTip = new ToolTip();

            toolTip.SetToolTip(this.pictureBox2, "Ultimo Accesso " + Environment.NewLine + loginAccess.USER_ID + Environment.NewLine + "ore: " + loginAccess.DT_LOGIN.ToString());
        }