Example #1
0
 protected void add_Click(object sender, EventArgs e)
 {
     error.Visible = false;
     success.Visible = false;
     encrypt en = new encrypt();
     SQL sql = new SQL();
     string username = user.Value.ToString().Trim();
     string password = pas.Value.ToString();
     string conf = confirm.Value.ToString();
     bool checknewUser = sql.checkNewUser(username);
     if (checknewUser)
     {
         errmsg.InnerText = "This user already exsists!";
         error.Visible = true;
     }
     else
     {
         if (password == conf && password != string.Empty)
         {
             string enpassword = en.Encrypt(password);
             sql.addUser(username, enpassword);
         }
         else
         {
             errmsg.InnerText = "The passwords do not match..";
             error.Visible = true;
         }
     }
     Reload();
 }
Example #2
0
        protected void reset_Click(object sender, EventArgs e)
        {
            error.Visible = false;
            success.Visible = false;
            int id = int.Parse(userDrop.SelectedItem.Value);
            string password = pas.Value.ToString();
            string conf = confirm.Value.ToString();
            encrypt en = new encrypt();
            if (password == conf && password != string.Empty)
            {
                string enpassword = en.Encrypt(password);
                try
                {
                    SQL sql = new SQL();
                    sql.resetPassword(id, enpassword);
                    successmsg.InnerText = "Password Reset";
                    success.Visible = true;
                }
                catch (Exception ex)
                {
                    errmsg.InnerText = "Error occoured changing password " + ex.Message.ToString();
                    error.Visible = true;
                }

            }
            else
            {
                errmsg.InnerText = "The passwords do not match..";
                error.Visible = true;
            }
        }
Example #3
0
 public bool authUser(string username, string password)
 {
     SqlCeConnection con = new SqlCeConnection(@"Data Source=|DataDirectory|\Cobweb_Quiz.sdf");
     SqlCeCommand cmd = new SqlCeCommand();
     cmd.Connection = con;
     SqlCeDataReader SQLReader;
     cmd.CommandText = "SELECT * FROM users WHERE (username = @username)";
     cmd.Parameters.AddWithValue("@username", username);
     try
     {
         con.Open();
         SQLReader = cmd.ExecuteReader();
         if (SQLReader.Read())
         {
             encrypt en = new encrypt();
             string dbpass = SQLReader[2].ToString();
             string confirm = en.Decrypt(dbpass);
             if (confirm == password)
             {
                 return true;
             }
             else
             {
                 return false;
             }
         }
         else
         {
             return false;
         }
     }
     catch (Exception ex)
     {
         //LOG?
         throw ex;
     }
     finally
     {
         con.Close();
     }
 }