Beispiel #1
0
        public string ResetPassword(string dealerUserName, string dealerEmail, string mtid)
        {
            string returnString = "0|Wrong details supplied";

            ClsDealer dl = new ClsDealer();

            string reqParams = $"dealerUserName:{dealerUserName}|dealerEmail:{dealerEmail}";

            //log the mobile request
            ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerUserName).ToString(), DateTime.Now, mtid + "|REQ", "ResetPassword", reqParams);

            //the algorithm seems ideal but kinda slow
            //List<char> l = mtid.ToList<char>();
            //l = l.OrderBy(o => Guid.NewGuid().ToString()).ToList();

            //StringBuilder newPassword = new StringBuilder();

            //foreach (char c in l)
            //    newPassword.Append(c.ToString());

            string newPassword = mtid.Substring(2, 6);

            if (dl.DealerEmailIsCorrect(dealerUserName, dealerEmail))
            {
                dl.ChangeDealerPassword(dealerUserName, MD5Crypt.MDee5(newPassword));

                PortalMailer mailer = new PortalMailer();

                mailer.subject = "Pawakad Password Reset Notification.";
                mailer.emailTo = dealerEmail;
                mailer.body    = "Dear " + dealerUserName + ",<br><br>"
                                 + "You initiated a password reset from your mobile device<br>"
                                 + $"You new password is {newPassword}<br>"
                                 + $"We advice you logon to the web and change t to something different and suitable for you<br>"
                                 + "<br><br> Thank You.";

                mailer.SendMail();
                returnString = $"1|newPassword|{newPassword}";
            }

            mtid += "|RESP";
            //log the mobile response
            ClsPayment.LogMobileRequest2(dl.GetDealerCode(dealerUserName).ToString(), DateTime.Now, mtid, "ResetPassword", returnString);

            return(returnString);
        }