Esempio n. 1
0
        public string AddNewUser()
        {
            string resultmsg = string.Empty;

            if (!string.IsNullOrEmpty(this.UserName) && !string.IsNullOrEmpty(this.Password))
            {
                this.EncryptionSeed = Guid.NewGuid().ToString();
                this.Password       = PortalUtility.HashString(this.EncryptionSeed, this.Password);

                try
                {
                    using (MySqlConnection conn = new MySqlConnection(PortalUtility.GetConnectionString("default")))
                    {
                        conn.Open();

                        MySqlCommand cmd = new MySqlCommand("Security_Insert_User", conn);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@pUsername", this.UserName);
                        cmd.Parameters.AddWithValue("@pPassword", this.Password);
                        cmd.Parameters.AddWithValue("@pEncryptionSeed", this.EncryptionSeed);
                        cmd.ExecuteNonQuery();
                        conn.Close();

                        resultmsg = "Success";
                    }
                }
                catch (Exception ex)
                {
                    resultmsg = ex.Message;
                }
            }

            return(resultmsg);
        }
Esempio n. 2
0
        public bool ValidateLogin(string password)
        {
            bool isvalid = false;

            if (!string.IsNullOrEmpty(this.UserName))
            {
                string encryptedpass = PortalUtility.HashString(this.EncryptionSeed, password);
                if (this.Password == encryptedpass)
                {
                    isvalid = true;
                }
            }

            return(isvalid);
        }
Esempio n. 3
0
        public static bool ValidateLogin(string username, string password)
        {
            bool isvalid = false;

            Login userlookup = new Login(username);

            if (!string.IsNullOrEmpty(userlookup.UserName))
            {
                string encryptedpass = PortalUtility.HashString(userlookup.EncryptionSeed, password);
                if (userlookup.UserName.ToLower() == username.ToLower() && userlookup.Password == encryptedpass)
                {
                    isvalid = true;
                }
            }

            return(isvalid);
        }