Exemplo n.º 1
0
        /// <summary>
        /// Tato metoda se vola, pokud klient zapomene sve heslo a necha si poslat nove. Nove nahodne vygenerovane 
        /// heslo bude poslano na email, ktery klient vyplnil pri registraci.
        /// </summary>
        /// <param name="email">adresa, na kterou bude zaslano nove heslo</param>
        public static void NewPasswordForClient(string email)
        {
            ClientTable ctab = new ClientTable();

            // Nejprve overime, zda email mame v databazi.
            if (ctab.CheckEmail(email))
            {
                /* Pokud existuje, muzeme vygenerovat nove heslo, provest zmeny v DB a poslat
                   klientovi email.
                */
                string newPass = GeneratePassword(6);
                string newPassHash = CalculateHashMD5(newPass);

                // Zmena hesla v DB
                ctab.ChangePassword(email, newPassHash);

                // Poslani emailu
                string text = String.Format("U Vaseho uctu bylo zmeneno heslo. Nove heslo je nyni {0}.", newPass);
                SendEmailToClient(email, text, "Knihovna SAN - Zmena hesla");
            }
            else
            {
                // Email v systemu neexistuje. Vyhodime expcetion.
                throw new ForgotPasswordException("Tento email neni v systemu evidovan.");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Provede registraci klienta podle UC1: Registrace klienta. 
        /// Oproti UC1 jsou zde dve zmeny:
        /// 1) Neposila se aktivacni email - pouze se posle email s vygenerovanym heslem
        /// 2) Login se negeneruje, uzivatel si ho zada sam. Uz vidim, jak nekdo bude chtit mit login treba CKFdjfnr154 :)
        /// </summary>
        /// <param name="client"></param>
        public static void RegisterClient(Client client)
        {
            // Doplnime udaje, ktere nebyly zadany v registracnim formulari

            string password = GeneratePassword(6);
            client.client_pass_hash = CalculateHashMD5(password);
            client.client_member_from = DateTime.Now;
            client.client_member_to = DateTime.Now.AddDays(1);
            client.client_isEmp = false;
            client.client_is_active = true;

            ClientTable cTab = new ClientTable();

            // Muze vyhodit vyjimku - catch blok v aspx strance
            cTab.Insert(client);

            // Odeslani emailu [zatim nebude odesilat nic]
            SendEmailToClient(client.client_email, password);
        }
        public void InsertActionReservation(ActionReservation actRes)
        {
            // Nejprve overime, zda ma klient aktivni ucet.
            Client c = new ClientTable().SelectOne(actRes.client_id);
            if (c.client_is_active == false)
                throw new MembershipExpiredException("Platnost clenstvi vyprsela.");

            using (MySqlConnection conn = new MySqlConnection(connString))
            {
                conn.Open();
                MySqlCommand command = new MySqlCommand(INSERT_ActionReservation, conn);

                /* Add parameters into the command */
                command.Parameters.AddWithValue("@act_reservation_date", actRes.act_reservation_date);
                command.Parameters.AddWithValue("@act_reservation_client_came", actRes.act_reservation_client_came);
                command.Parameters.AddWithValue("@action_id", actRes.action_id);
                command.Parameters.AddWithValue("@client_id", actRes.client_id);

                /* Executes the command */
                command.ExecuteNonQuery();
            }
        }