Beispiel #1
0
        protected void btnOnlinePayment_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                string MerchantCode     = Globals.GATEWAY_MERCHANTCODE;
                string Currency         = "UGX";
                string ItemDesc         = $"Payment For Sale [ {GenerateTransactionIDIfNotExists()} ]";
                string CustomerRef      = Session["CustID"] as string;
                string Amount           = GetItemTotal();
                string Password         = SharedCommons.GenearetHMACSha256Hash(Globals.GATEWAY_SECRET_KEY, Globals.GATEWAY_PASSWORD);
                string ReturnUrl        = Globals.RETURN_URL;
                string VendorCode       = Globals.GATEWAY_VENDORCODE;
                string VendorTranId     = GenerateTransactionIDIfNotExists();
                string datatToSign      = VendorCode + MerchantCode + Amount + ItemDesc + Currency + ReturnUrl + VendorTranId;
                string DigitalSignature = SharedCommons.GenearetHMACSha256Hash(Globals.GATEWAY_SECRET_KEY, datatToSign);
                string RequestData      = "VENDORCODE=" + VendorCode + "&PASSWORD="******"&VENDOR_TRANID=" + VendorTranId + "&ITEM_TOTAL=" + Amount + "&ITEM_DESCRIPTION=" + ItemDesc + "&CURRENCY=" + Currency + "&RETURN_URL=" + ReturnUrl + "&DIGITAL_SIGNATURE=" + DigitalSignature + "&MERCHANTCODE=" + MerchantCode + "&CUSTOMER_REF=" + CustomerRef;
                string URL = Globals.URL_FOR_PEGASUS_PAYMENTS_GATEWAY + "?" + RequestData;
                Response.Redirect(URL);
            }
            catch (Exception ex)
            {
                //display error
                ShowErrorMsg(SharedLogic.INTERNAL_ERROR_MSG);

                //log error
                SharedLogic.TcmpTestCore.LogError($"EXCEPTION:{ex.Message}", $"{this.GetType().Name}-{SharedLogic.GetCurrentMethod()}", "N/A");
            }
        }
Beispiel #2
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            InterConnect.LeshLaonApi.ClientDetails clientDet = GetClientDetails();
            if (string.IsNullOrEmpty(clientDet.ClientPhoto) || string.IsNullOrEmpty(clientDet.IDPhoto))
            {
                ShowMessage("Please Upload Photo(s)", true);
                return;
            }
            string Password = clientDet.ClientPassword;
            clientDet.ClientPassword = SharedCommons.GenerateUserPassword(clientDet.ClientPassword);
            Result client_save = Client.SaveClientDetails(clientDet);

            if (client_save.StatusCode != "0")
            {
                //MultiView2.ActiveViewIndex = 0;
                ShowMessage(client_save.StatusDesc, true);
                return;
            }
            ShowMessage("CLIENT SAVED SUCCESSFULLY", false);
            Clear_controls();
            bll.SendCredentialsToClientUser(clientDet, Password);
            bll.InsertIntoAuditLog("USER-CREATION", "SYSTEMUSERS", user.CompanyCode, user.UserId, "USER " + clientDet.ClientNo + " CREATED SUCCESSFULLY");
        }
        catch (Exception ex)
        {
        }
    }
Beispiel #3
0
        public override bool IsValid()
        {
            if (string.IsNullOrEmpty(Email) && string.IsNullOrEmpty(Phone))
            {
                StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                StatusDesc = "Please Supply an Email or Phone Number";
                return(false);
            }

            string propertiesThatCanBeNull = $"{nameof(Id)}|{nameof(Email)}|{nameof(Phone)}";
            string nullCheckResult         = SharedCommons.CheckForNulls(this, propertiesThatCanBeNull);

            if (nullCheckResult != SharedCommonsGlobals.SUCCESS_STATUS_TEXT)
            {
                StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                StatusDesc = nullCheckResult;
                return(false);
            }

            if (!string.IsNullOrEmpty(Email) && !SharedCommons.IsValidEmail(Email))
            {
                StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                StatusDesc = "Please Supply an valid Email Address";
                return(false);
            }

            if (!string.IsNullOrEmpty(Phone) && !SharedCommons.IsValidUgPhoneNumber(Phone))
            {
                StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                StatusDesc = "Please Supply an valid Phone";
                return(false);
            }

            return(base.IsValid());
        }
Beispiel #4
0
        public SystemUser Login(string Username, string Password)
        {
            SystemUser result = new SystemUser();

            try
            {
                //quick validations
                if (string.IsNullOrEmpty(Username))
                {
                    result.StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                    result.StatusDesc = $"Please Supply a {nameof(Username)}";
                    return(result);
                }
                if (string.IsNullOrEmpty(Password))
                {
                    result.StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                    result.StatusDesc = $"Please Supply a {nameof(Password)}";
                    return(result);
                }

                //find the first user whose username is the one supplied
                SystemUser user = SystemUser.QueryWithStoredProc("GetSystemUserByID", Username).FirstOrDefault();

                //oops no user found..stop
                if (user == null)
                {
                    result.StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                    result.StatusDesc = $"Invalid Username or Password";
                    return(result);
                }

                //hash the password supplied
                string hashedPassword = SharedCommons.GenerateMD5Hash(Password);

                //compare hashes
                if (hashedPassword != user.Password)
                {
                    //no match..stop
                    result.StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                    result.StatusDesc = $"Invalid Username or Password";
                    return(result);
                }

                //user is authentic
                result            = user;
                result.StatusCode = SharedCommonsGlobals.SUCCESS_STATUS_CODE;
                result.StatusDesc = SharedCommonsGlobals.SUCCESS_STATUS_TEXT;
            }
            catch (Exception ex)
            {
                result.StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                result.StatusDesc = $"ERROR: {ex.Message}";
            }

            return(result);
        }
Beispiel #5
0
        private string GenerateTransactionIDIfNotExists()
        {
            //retrieve sale ID
            string tranId = Session["SaleID"] as string;

            //if no sale ID is not found...create one
            tranId = tranId ?? SharedCommons.GenerateUniqueId("SALE-");

            return(tranId);
        }
Beispiel #6
0
        public void RegisterSaleItemsTest_ValidInput_ExpectSuccess()
        {
            SaleItem item = new SaleItem
            {
                ItemId = SharedCommons.GenerateUniqueId("ITEM-"),
                SaleId = SharedCommons.GenerateUniqueId("SALE-")
            };
            TcmpCore core   = new TcmpCore();
            Result   result = core.RegisterSaleItems(item);

            Assert.AreEqual(result.StatusDesc, SharedCommonsGlobals.SUCCESS_STATUS_TEXT);
        }
Beispiel #7
0
        public static void Main(string[] args)
        {
            string       QueuePath = @".\private$\TestQueue";;
            CommonResult result    = new CommonResult();

            result.StatusCode = SharedCommonsGlobals.SUCCESS_STATUS_CODE;
            result.StatusDesc = SharedCommonsGlobals.SUCCESS_STATUS_TEXT;
            CommonResult insertResult = SharedCommons.InsertIntoMSMQ(QueuePath, result);
            Message      message      = SharedCommons.PeekCopyOfTopItemFromMSMQ(QueuePath, typeof(CommonResult));

            result = message.Body as CommonResult;
            bool isValid = SharedCommons.IsValidUgPhoneNumber("0785975800");
        }
Beispiel #8
0
        public override bool IsValid()
        {
            string propertiesThatCanBeNull = $"{nameof(Id)}|{nameof(PaymentNarration)}";
            string nullCheckResult         = SharedCommons.CheckForNulls(this, propertiesThatCanBeNull);

            if (nullCheckResult != SharedCommonsGlobals.SUCCESS_STATUS_TEXT)
            {
                StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                StatusDesc = nullCheckResult;
                return(false);
            }

            Payment duplicatePayment = Payment.QueryWithStoredProc("GetPaymentByPaymentSystemCodeAndID", PaymentId, PaymentSystemCode).FirstOrDefault();

            if (duplicatePayment != null)
            {
                StatusCode = SharedCommonsGlobals.SUCCESS_STATUS_CODE;
                StatusDesc = SharedCommonsGlobals.SUCCESS_STATUS_TEXT;
                return(false);
            }

            PaymentSystem system = PaymentSystem.QueryWithStoredProc("GetPaymentSystemByID", PaymentSystemCode).FirstOrDefault();

            if (system == null)
            {
                StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                StatusDesc = "INVALID PAYMENT SYSTEM CODE OR PASSWORD";
                return(false);
            }

            string hashedPassword = SharedCommons.GenearetHMACSha256Hash(system.SecretKey, Password);

            if (hashedPassword != system.Password)
            {
                StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                StatusDesc = "INVALID PAYMENT SYSTEM CODE OR PASSWORD";
                return(false);
            }

            string dataToSign = PaymentSystemCode + Password + PaymentAmount + PaymentId + PaymentChannel + PayerContact + PayerName;
            string hmacHash   = SharedCommons.GenearetHMACSha256Hash(system.SecretKey, dataToSign);

            if (DigitalSignature != hmacHash)
            {
                StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                StatusDesc = "INVALID DIGITAL SIGNATURE";
                return(false);
            }

            return(base.IsValid());
        }
Beispiel #9
0
        public void RegisterSaleTest_ValidInput_ExpectSuccess()
        {
            Sale sale = new Sale
            {
                SaleID     = SharedCommons.GenerateUniqueId("SALE-"),
                CustomerId = "Nsubugak",
                TotalCost  = 0,
                Tax        = 0
            };
            TcmpCore core   = new TcmpCore();
            Result   result = core.RegisterSale(sale);

            Assert.AreEqual(result.StatusDesc, SharedCommonsGlobals.SUCCESS_STATUS_TEXT);
        }
Beispiel #10
0
        public override bool IsValid()
        {
            string propertiesThatCanBeNull = $"{nameof(Id)}";
            string nullCheckResult         = SharedCommons.CheckForNulls(this, propertiesThatCanBeNull);

            if (nullCheckResult != SharedCommonsGlobals.SUCCESS_STATUS_TEXT)
            {
                StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                StatusDesc = nullCheckResult;
                return(false);
            }

            return(base.IsValid());
        }
Beispiel #11
0
        public void RegisterItemTest_ValidInput_ExpectSuccess()
        {
            Item item = new Item
            {
                ItemCode   = SharedCommons.GenerateUniqueId("ITEM-"),
                CreatedBy  = "admin",
                ItemCount  = 10,
                ItemName   = "Shoes",
                ItemPrice  = 2000,
                ModifiedBy = "admin"
            };

            TcmpCore core   = new TcmpCore();
            Result   result = core.RegisterItem(item);

            Assert.AreEqual(result.StatusDesc, SharedCommonsGlobals.SUCCESS_STATUS_TEXT);
        }
Beispiel #12
0
        public Result RegisterSystemUser(SystemUser user)
        {
            Result result = new Result();

            try
            {
                if (!user.IsValid())
                {
                    result.StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                    result.StatusDesc = $"{user.StatusDesc}";
                    return(result);
                }

                //check among the existing users for someone with the same username
                SystemUser old = SystemUser.QueryWithStoredProc("GetSystemUserByID", user.Username).FirstOrDefault();

                //a current user has been found with the same username
                if (old != null)
                {
                    result.StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                    result.StatusDesc = $"Username Already in Use. Please try another Username";
                    return(result);
                }

                //hash user password
                user.Password = SharedCommons.GenerateMD5Hash(user.Password);

                //save the user
                user.Save();

                //success
                result.ResponseId = user.Username;
                result.StatusCode = SharedCommonsGlobals.SUCCESS_STATUS_CODE;
                result.StatusDesc = SharedCommonsGlobals.SUCCESS_STATUS_TEXT;
            }
            catch (Exception ex)
            {
                result.StatusCode = SharedCommonsGlobals.FAILURE_STATUS_CODE;
                result.StatusDesc = $"ERROR: {ex.Message}";
            }

            return(result);
        }
Beispiel #13
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            bool isHuman = captchaBox.Validate(txtCaptcha.Text);
            txtCaptcha.Text = null;
            if (!isHuman)
            {
                //The Captcha entered by user is Invalid.
                //ShowMessage("Captcha doesnot match", true);
                lblCaptchaError.Visible   = true;
                lblCaptchaError.Text      = "Captcha doesnot match";
                lblCaptchaError.ForeColor = System.Drawing.Color.Red; lblmsg.Font.Bold = true;
                return;
            }
            //The Captcha entered by user is Valid.
            lblCaptchaError.Visible = false;

            InterConnect.LeshLaonApi.ClientDetails clientDet = GetClientDetails();

            string Password = clientDet.ClientPassword;
            clientDet.ClientPassword = SharedCommons.GenerateUserPassword(clientDet.ClientPassword);
            Result client_save = Client.SaveClientDetails(clientDet);

            if (client_save.StatusCode != "0")
            {
                //MultiView2.ActiveViewIndex = 0;
                ShowMessage(client_save.StatusDesc, true);
                return;
            }
            //ShowMessage("", false);
            lblmsg.Text      = "CLIENT SAVED SUCCESSFULLY";
            lblmsg.ForeColor = System.Drawing.Color.Green; lblmsg.Font.Bold = true;
            Clear_controls();
            bll.SendCredentialsToClientUser(clientDet, Password);
            bll.InsertIntoAuditLog("USER-CREATION", "SYSTEMUSERS", "Lensh", txtClientNo.Text, "USER " + clientDet.ClientNo + "CREATED SUCCESSFULLY");
            Response.Redirect("Default.aspx");
        }
        catch (Exception ex)
        {
        }
    }
Beispiel #14
0
        public void PayForTransactionTest_ValidInput_ExpectSuccess()
        {
            Payment payment = new Payment
            {
                DigitalSignature  = SharedCommons.GenerateRandomString(),
                Password          = "******",
                PayerContact      = "0794132389",
                PaymentChannel    = "BANK",
                PaymentId         = "1325621",
                PaymentNarration  = "Test Payment",
                PaymentSystemCode = "SBU",
                PaymentType       = "CASH",
                PayerName         = "Nsubuga Kasozi"
            };

            TcmpCore core   = new TcmpCore();
            Result   result = core.PayForTransaction(payment);

            Assert.AreEqual(result.StatusDesc, SharedCommonsGlobals.SUCCESS_STATUS_TEXT);
        }
Beispiel #15
0
        protected void btnRegisterItem_Click(object sender, EventArgs e)
        {
            try
            {
                SystemUser user = Session["User"] as SystemUser;

                //create item
                Item item = new Item
                {
                    CreatedBy = user.Username,
                    ItemCode  = Request.QueryString["ItemId"] == null?SharedCommons.GenerateUniqueId("ITEM-") : Request.QueryString["ItemId"],
                                    ItemCount  = SharedCommons.GetIntFromStringDefaultsToZero(txtItemCount.Text),
                                    ItemImage  = GetBase64StringOfImageUploaded(),
                                    ItemName   = txtItemName.Text,
                                    ItemPrice  = SharedCommons.GetIntFromStringDefaultsToZero(txtPrice.Text),
                                    ModifiedBy = user.Username,
                };

                Result result = SharedLogic.TcmpTestCore.RegisterItem(item);

                //failed to save
                if (result.StatusCode != SharedCommonsGlobals.SUCCESS_STATUS_CODE)
                {
                    lblInfoMsg.Text = result.StatusDesc;
                    return;
                }

                //success
                lblInfoMsg.Text = "Item Registered Successfully";

                //reload items from database
                ItemsAvailableForSale = LoadItems();
            }
            catch (Exception ex)
            {
                ShowErrorMsg(SharedLogic.INTERNAL_ERROR_MSG);

                //log error
                SharedLogic.TcmpTestCore.LogError($"EXCEPTION:{ex.Message}", $"{this.GetType().Name}-{SharedLogic.GetCurrentMethod()}", "N/A");
            }
        }
Beispiel #16
0
    protected void btnApprove_Click()
    {
        Label lblmsg = (Label)Master.FindControl("lblmsg");

        try
        {
            string     msg      = "";
            SystemUser aclient  = GetSystemUserToEdit();
            string     Password = aclient.Password;
            aclient.Password = SharedCommons.GenerateUserPassword(aclient.Password);
            if (chkActive.Checked)
            {
                Result result = bll.ReActivateUser(aclient, user.UserId, "ACTIVATE");
                if (result.StatusCode != Globals.SUCCESS_STATUS_CODE)
                {
                    msg = "FAILED: " + result.StatusDesc;
                    bll.ShowMessage(lblmsg, msg, true, Session);
                    return;
                }

                msg = "SYSTEM USER DETAILS ACTIVATED SUCCESSFULLY. AN EMAIL WITH CREDENTIALS HAS BEEN SENT TO THE USER EMAIL";
                bll.ShowMessage(lblmsg, msg, false, Session);
                Clear_contrls();
                bll.SendCredentialsToUser(aclient, Password);
                bll.InsertIntoAuditLog("APPROVE-USER", "SYSTEMUSERS", user.CompanyCode, user.UserId, "USER " + aclient.UserId + " ACTIVATED AND APPROVED SUCCESSFULLY");
                return;
            }

            msg = "SYSTEM USER STILL INACTIVE";
            bll.ShowMessage(lblmsg, msg, true, Session);
        }
        catch (Exception ex)
        {
            bll.LogError(user.CompanyCode, "", "APPROVE-SYSTEM USER" + ex.Message + ex.StackTrace, "EXCEPTION", "", "");

            bll.ShowMessage(lblmsg, ex.Message, true, Session);
        }
    }
Beispiel #17
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        try
        {
            SystemUser RegUser  = GetSystemUserDetails();
            string     Password = RegUser.Password;
            RegUser.Password = SharedCommons.GenerateUserPassword(RegUser.Password);
            //    bool reset = CheckBox1.Checked;
            string check_status = validate_input(RegUser.Name, RegUser.Name, RegUser.UserId, RegUser.RoleCode);


            if (!check_status.Equals("OK"))
            {
                ShowMessage(check_status, true);
            }
            else
            {
                Result user_save = Client.SaveSystemUser(RegUser);

                if (user_save.StatusCode != "0")
                {
                    //MultiView2.ActiveViewIndex = 0;
                    ShowMessage(user_save.StatusDesc, true);
                    return;
                }
                ShowMessage("USER SAVED SUCCESSFULLY", false);
                Clear_contrls();
                //bll.SendCredentialsToUser(RegUser, Password);
                bll.InsertIntoAuditLog("USER-CREATION", "SYSTEMUSERS", user.CompanyCode, user.UserId, "USER " + RegUser.UserId + " CREATED SUCCESSFULLY");
            }
        }
        catch (Exception ex)
        {
            ShowMessage(ex.Message, true);
        }
    }
Beispiel #18
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        Label LblMsg = (Label)Master.FindControl("lblMsg");

        try
        {
            string OldPassword       = txtOldPasswd.Text.Trim();
            string NewPassword       = txtNewPasswd.Text.Trim();
            string ConfirmedPassword = txtConfirm.Text.Trim();

            if (NewPassword != ConfirmedPassword)
            {
                string msg = "Msg: Your New Password Doesnt match the confirmed Password";
                bll.ShowMessage(LblMsg, msg, true);
                txtOldPasswd.Focus();
            }

            else if (SharedCommons.GenerateMD5Hash(OldPassword) != user.Password)
            {
                string msg = "Msg: Your Old Password Is Incorrect";
                txtOldPasswd.Focus();
                bll.ShowMessage(LblMsg, msg, true);
            }
            if (OldPassword.Equals(""))
            {
                ShowMessage("Please Enter your Old Password", true);
                txtOldPasswd.Focus();
            }
            else if (NewPassword.Equals(""))
            {
                ShowMessage("Please Enter your New Password", true);
                txtNewPasswd.Focus();
            }
            else if (ConfirmedPassword.Equals(""))
            {
                ShowMessage("Please Confirm your New Password", true);
                txtConfirm.Focus();
            }

            else
            {
                if (SharedCommons.GenerateMD5Hash(NewPassword) == SharedCommons.GenerateMD5Hash(OldPassword))
                {
                    string msg = "Your new password can't be Similar to the Old One";
                    bll.ShowMessage(LblMsg, msg, true);
                }
                else if (!bll.ObeysPasswordPolicy(NewPassword, user.CompanyCode))
                {
                    string msg = "Your new password should have a mixture of uppercase & lowercase letters, special characters i.e ?,$ and numbers";
                    bll.ShowMessage(LblMsg, msg, true);
                }
                else if (bll.PasswordHasBeenUsed(user.UserId, SharedCommons.GenerateMD5Hash(NewPassword)))
                {
                    bll.ShowMessage(LblMsg, "Your New Password can't be Similar To The Recent Two Passwords", true);
                }
                else
                {
                    user.Password   = SharedCommons.GenerateMD5Hash(NewPassword);
                    user.ModifiedBy = user.UserId;
                    Result result = bll.ChangeUsersPassword(user.UserId, user.CompanyCode, user.Password, user.RoleCode);    //, false, "PASSWORD");
                    if (result.StatusCode == "0")
                    {
                        bll.Log("PasswordTracker_Update", new string[] { user.UserId, SharedCommons.GenerateMD5Hash(OldPassword), user.UserId, bll.getIp() });
                        string msg = "Password Changed Successfully";
                        bll.ShowMessage(LblMsg, msg, false);
                    }
                    else
                    {
                        string msg = result.StatusDesc;
                        bll.ShowMessage(LblMsg, msg, true);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            ShowMessage(ex.Message, true);
        }
    }
Beispiel #19
0
 protected void btnChangenewPassword_Click(object sender, EventArgs e)
 {
     try
     {
         string newpassword     = txtnewpassword.Text;
         string confirmPassword = txtConfirmnewpassword.Text;
         if (newpassword.Equals(""))
         {
             ShowMessage("ENTER NEW PASSWORD", true);
             txtnewpassword.Focus();
         }
         else if (confirmPassword.Equals(""))
         {
             ShowMessage("CONFIRM NEW PASSWORD", true);
             txtConfirmnewpassword.Focus();
         }
         else
         {
             if (newpassword.Equals(confirmPassword))
             {
                 if (Session["PassUser"] != null)
                 {
                     SystemUser user = Session["PassUser"] as SystemUser;
                     if (!user.UserId.Equals(""))
                     {
                         if (SharedCommons.GenerateMD5Hash(newpassword) == user.Password)
                         {
                             ShowMessage("YOUR NEW PASSWORD CANNOT BE THE SAME AS THE PREVIOUS ONE", true);
                         }
                         else if (!bll.ObeysPasswordPolicy(newpassword, user.CompanyCode))
                         {
                             ShowMessage("Your new password should contain atleast one uppercase and lowercase letters, a special character,a number and Should be atleast 8 characters in Length", true);
                         }
                         else if (bll.PasswordHasBeenUsed(user.UserId, SharedCommons.GenerateMD5Hash(newpassword)))
                         {
                             ShowMessage("You have used this password before, please create another one", true);
                         }
                         else
                         {
                             string oldPassword = user.Password;
                             user.Password = SharedCommons.GenerateMD5Hash(newpassword);
                             Result result = bll.ChangeUsersPassword(user.UserId, user.CompanyCode, user.Password, user.RoleCode);
                             if (result.StatusCode == "0")
                             {
                                 bll.Log("PasswordTracker_Update", new string[] { user.UserId, oldPassword, ip });
                                 string msg = "Password Changed Successfully";
                                 ShowMessage(msg, false);
                                 MultiView1.ActiveViewIndex = 0;
                                 clearControls();
                             }
                             else
                             {
                                 string msg = result.StatusDesc;
                                 ShowMessage(msg, true);
                             }
                         }
                     }
                     else
                     {
                         ShowMessage("FAILED TO DETERMINE USER DETAILS", true);
                     }
                 }
                 else
                 {
                     ShowMessage("FAILED TO DETERMINE USER DETAILS", true);
                 }
             }
             else
             {
                 ShowMessage("PASSWORD MISMATCH", true);
             }
         }
     }
     catch (Exception ex)
     {
         ShowMessage("FAILED: " + ex.Message, true);
     }
 }
Beispiel #20
0
    protected void btnForgotPassword_Click(object sender, EventArgs e)
    {
        SystemUser user = bll.GetSystemUserByUserId(txtUserId.Text);

        try
        {
            // validate the Captcha to check we're not dealing with a bot
            //string userInput = txtCaptcha.Text.Trim().ToUpper();
            //bool isHuman = ExampleCaptcha.Validate(userInput);
            //txtCaptcha.Text = null; // clear previous user input

            //if (isHuman)
            //{
            //    // TODO: proceed with protected action
            //}
            //else
            //{
            //    ShowMessage("INCORRECT CAPTCHA", false);
            //    return;
            //}
            //get user using his UserId


            //unable to find user
            if (user.StatusCode != "0")
            {
                string msg = user.StatusDesc;
                bll.LogUserLogin("PORTAL", ip, user.UserId, this.Session.SessionID, user.StatusCode, user.StatusDesc, "LOGIN");

                bll.InsertIntoAuditLog("LOGIN", "", user.CompanyCode, user.UserId, "Unsuccessfull Password Reset of User with ID :" + user.UserId + " Error: " + msg);
                ShowMessage(msg, true);
                return;
            }
            ////use redis to save to cache
            //string host = "localhost";

            //string key = user.UserId;
            //// Retrieve data from the cache using the key
            //string data = Get(host, key);
            //int i = 1;

            //if (string.IsNullOrEmpty(data))
            //{
            //    // Store data in the cache
            //    Save(host, key, i.ToString());
            //}
            //else
            //{
            //    if (Convert.ToInt16(data) >= 3)
            //    {
            //        bll.ShowMessage(lblmsg, "Password cannot be changed more than 3 times in 24 hours", true);
            //        return;
            //    }
            //    else
            //    {
            //        // Store data in the cache with increased count
            //        i = Convert.ToInt16(data) + 1;
            //        Save(host, key, i.ToString());
            //    }
            //}
            //generate a new password for the user
            string Password = bll.GeneratePassword();
            user.Password = SharedCommons.GenerateMD5Hash(Password);
            ////user.ResetPassword = true;

            //update the password of the user at Pegasus
            Result result = bll.UpdateUserPassword(user);

            //failed to update
            if (result.StatusCode != "0")
            {
                ShowMessage("FAILED: " + result.StatusDesc, false);
                return;
            }

            //send the user the new credentials
            Result sendResult = bll.ResendCredentials(user, "Password", Password);

            //failed to send mail
            if (sendResult.StatusCode != "0")
            {
                //ShowMessage("FAILED: PASSWORD WAS RESET BUT EMAIL SEND TO [" + user.Email + "] FAILED : " + result.StatusDesc, false);
                //with no mail displayed to the user
                ShowMessage("FAILED: PASSWORD WAS RESET BUT EMAIL SEND TO YOUR ASSOCIATED MAIL ACCOUNT FAILED : " + result.StatusDesc, false);
                return;
            }

            //we are good
            //ShowMessage("YOUR PASSWORD HAS BEEN RESET AND AN EMAIL HAS BEEN SENT TO " + user.Email, false);
            //with no mail displayed to the user
            ShowMessage("YOUR PASSWORD HAS BEEN RESET AND AN EMAIL HAS BEEN SENT TO YOUR ASSOCIATED MAIL ACCOUNT", false);
            MultiView1.SetActiveView(View2);
        }
        catch (Exception ex)
        {
            bll.LogError(user.CompanyCode, "", "FORGOT-PWD" + ex.Message + ex.StackTrace, "", "EXCEPTION", "");
            ShowMessage("FAILED: INTERNAL ERROR", true);
        }
    }
Beispiel #21
0
    private void System_login(string UserId, string passwd)
    {
        string     msg  = "";
        SystemUser user = bll.GetSystemUserByUserId(UserId);//process_file.LoginDetails(userId, passwd);

        if (user.StatusCode != Globals.SUCCESS_STATUS_CODE)
        {
            msg = "FAILED: " + user.StatusDesc;
            bll.InsertIntoAuditLog("LOGIN", "", user.CompanyCode, UserId, "Unsuccessfull login of User with ID :" + UserId + " Error: " + msg);
            ShowMessage(msg, true);
            return;
        }


        string md5HashOfPassword = SharedCommons.GenerateMD5Hash(passwd);

        if (user.Password.ToUpper() != md5HashOfPassword.ToUpper())
        {
            msg = "FAILED: INVALID USERNAME OR PASSWORD SUPPLIED";
            bll.InsertIntoAuditLog("LOGIN", "", user.CompanyCode, UserId, "Unsuccessfull login of User with ID :" + UserId + " Error: " + msg);

            if (MaxInvalidLoginsIsExceeded())
            {
                bll.InsertIntoAuditLog("DE-ACTIVATION", "", user.CompanyCode, user.UserId, "Deactivated: Maximum number of Invalid Logins Reached by User[" + user.UserId + "]");
                bll.DeactivateUser(user.UserId, "PORTAL", ip, user.CompanyCode);// user.PhoneNumber
                msg = "User Credentials Deactivated: Maximum number of Invalid Logins Reached";
            }


            bll.LogUserLogin("PORTAL", ip, user.UserId, this.Session.SessionID, "555", msg, "LOGIN");

            ShowMessage(msg, true);
            return;
        }

        //user has to reset password
        if (user.ResetPassword)
        {
            msg = "RESET PASSWORD";
            bll.LogUserLogin("PORTAL", ip, user.UserId, this.Session.SessionID, "111", msg, "LOGIN");

            bll.InsertIntoAuditLog("LOGIN", "", user.CompanyCode, user.UserId, "Unsuccessfull login of User with ID :" + user.UserId + " Error: " + msg);
            CallResetPassword(user);
            ShowMessage(msg, true);
            return;
        }

        //user password has expired
        //if (bll.PasswordExpired(user.UserId, user.CompanyCode, ip))
        //{
        //    msg = "YOUR PASSWORD EXPIRED AND NEEDS TO BE CHANGED";
        //    bll.LogUserLogin("PORTAL", "", ip, user.UserId, this.Session.SessionID, "222", msg, "LOGIN");

        //    CallResetPassword(user);

        //    bll.ShowMessage(lblmsg, msg, true);
        //    return;
        //}


        AssignSessionVariables(user);

        ShowMessage("System Logon denied", true);
    }
Beispiel #22
0
    //protected void ddlAreas_DataBound(object sender, EventArgs e)
    //{
    //    ddlAreas.Items.Insert(0, new ListItem(" Select Vendor ", "0"));
    //}

    protected void btnEdit_Click(object sender, EventArgs e)
    {
        Label lblmsg = (Label)Master.FindControl("lblmsg");

        try
        {
            Result     result;
            string     msg      = "";
            SystemUser aclient  = GetSystemUserToEdit();
            string     Password = aclient.Password;
            aclient.Password = SharedCommons.GenerateUserPassword(aclient.Password);

            if (ChkReset.Checked)
            {
                result = bll.ReActivateUser(aclient, user.UserId, "RESET");
                if (result.StatusCode != Globals.SUCCESS_STATUS_CODE)
                {
                    msg = "FAILED: " + result.StatusDesc;
                    bll.ShowMessage(lblmsg, msg, true, Session);
                    return;
                }

                msg = "SYSTEM USER DETAILS RESET SUCCESSFULLY";
                bll.ShowMessage(lblmsg, msg, false, Session);
                Clear_contrls();
                bll.SendCredentialsToUser(aclient, Password);
                bll.InsertIntoAuditLog("RESET-USER", "SYSTEMUSERS", user.CompanyCode, user.UserId, "USER " + aclient.UserId + " PASSWORD RESET SUCCESSFULLY");
                //return;
            }

            else if (chkActive.Checked)
            {
                result = bll.ReActivateUser(aclient, user.UserId, "JUSTACTIVATE");
                if (result.StatusCode != Globals.SUCCESS_STATUS_CODE)
                {
                    msg = "FAILED: " + result.StatusDesc;
                    bll.ShowMessage(lblmsg, msg, true, Session);
                    return;
                }

                msg = "SYSTEM USER ACTIVATED SUCCESSFULLY.";
                bll.ShowMessage(lblmsg, msg, false, Session);
                Clear_contrls();
                bll.SendCredentialsToUser(aclient, Password);
                bll.InsertIntoAuditLog("ACTIVATE-USER", "SYSTEMUSERS", user.CompanyCode, user.UserId, "USER " + aclient.UserId + " ACTIVATED SUCCESSFULLY");
                //return;
            }
            else if (ChkDeactivate.Checked)
            {
                result = bll.ReActivateUser(aclient, user.UserId, "DEACTIVATE");
                if (result.StatusCode != Globals.SUCCESS_STATUS_CODE)
                {
                    msg = "FAILED: " + result.StatusDesc;
                    bll.ShowMessage(lblmsg, msg, true, Session);
                    return;
                }

                msg = "SYSTEM USER DETAILS DE-ACTIVATED SUCCESSFULLY.";
                bll.ShowMessage(lblmsg, msg, false, Session);
                Clear_contrls();
                //bll.SendCredentialsToUser(aclient, Password);
                bll.InsertIntoAuditLog("DEACTIVATE-USER", "SYSTEMUSERS", user.CompanyCode, user.UserId, "USER " + aclient.UserId + " DE-ACTIVATED SUCCESSFULLY");
                //return;
            }
            else
            {
                result = bll.ReActivateUser(aclient, user.UserId, "EDITUSER");
                if (result.StatusCode != Globals.SUCCESS_STATUS_CODE)
                {
                    msg = "FAILED: " + result.StatusDesc;
                    bll.ShowMessage(lblmsg, msg, true, Session);
                    return;
                }

                msg = "SYSTEM USER DETAILS EDITED SUCCESSFULLY.";
                bll.ShowMessage(lblmsg, msg, false, Session);
                Clear_contrls();
                //bll.SendCredentialsToUser(aclient, Password);
                bll.InsertIntoAuditLog("EDIT-USER", "SYSTEMUSERS", user.CompanyCode, user.UserId, "USER " + aclient.UserId + " EDITED SUCCESSFULLY");
            }
        }
        catch (Exception ex)
        {
            bll.LogError(user.CompanyCode, "", "EDIT-SYSTEM USER" + ex.Message + ex.StackTrace, "EXCEPTION", "", "");
            bll.ShowMessage(lblmsg, ex.Message, true, Session);
        }
    }