Beispiel #1
0
        public ActionResult ChangePassword(FormCollection formCollection)
        {
            string emailAddress = "";
            if (Session["LoginEmailAddress"] != null)
            {
                emailAddress = Convert.ToString(Session["LoginEmailAddress"]);
            }
            else
            {
                return RedirectToAction("Index", "User");
            }

            UsersBAL objUserBAL = new UsersBAL();
            logger.Debug("Change Password");
            string currentpassword = "", password = "", confirmPassword = "";
            foreach (string key in formCollection.Keys)
            {
                if (key == "currentpassword")
                {
                    currentpassword = formCollection[key].Trim();
                }
                else if (key == "password")
                {
                    password = formCollection[key].Trim();
                }
                else if (key == "confirmpassword")
                {
                    confirmPassword = formCollection[key].Trim();
                }
            }

            logger.Debug("Validations check");
            if (string.IsNullOrEmpty(currentpassword) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(confirmPassword) || string.IsNullOrEmpty(emailAddress))
            {
                return RedirectToAction("Message", "MessageDisplay", new { E = 41 });
            }
            if (password.Length < 6)
            {
                return RedirectToAction("Message", "MessageDisplay", new { E = 46 });
            }
            if (password != confirmPassword)
            {
                return RedirectToAction("Message", "MessageDisplay", new { E = 36 });
            }

            logger.Debug("Call Change password Method");
            int retVal = ChangePasswordMethod(emailAddress, currentpassword, password);
            if (retVal == 1)
            {
                return RedirectToAction("Message", "MessageDisplay", new { E = 45 });
            }
            else
            {
                return RedirectToAction("Message", "MessageDisplay", new { E = 47 });
            }
        }
Beispiel #2
0
 /// <summary>
 /// UserAlreadyExist
 /// </summary>
 /// <param name="strEmailAddress"></param>
 /// <param name="password"></param>
 /// <returns></returns>
 public int UserAlreadyExist(string strEmailAddress)
 {
     UsersBAL objUser = new UsersBAL();
     try
     {
         List<UsersModel> lstUsersModel = objUser.GetPasswordByEmail(strEmailAddress);
         if (lstUsersModel != null && lstUsersModel.Count > 0)
         {
             return 1;
         }
         else
         {
             return 0;
         }
     }
     catch
     {
         return 2;
     }
     finally
     {
         objUser = null;
     }
 }
Beispiel #3
0
 /// <summary>
 /// RegisterNewUser
 /// </summary>
 /// <param name="strEmailAddress"></param>
 /// <param name="password"></param>
 /// <returns></returns>
 public int UpdateUserStatus(Int32 UsersID, string strStatus, string encodestring)
 {
     UsersBAL objUser = new UsersBAL();
     try
     {
         int iUpdateSuccessfully = objUser.UpdateUserStatus(UsersID, strStatus, encodestring);
         return iUpdateSuccessfully;
     }
     catch
     {
         return 2;
     }
     finally
     {
         objUser = null;
     }
 }
Beispiel #4
0
        public int SendMailForRenewPassword(string strEmail)
        {
            try
            {
                UsersBAL objUser = new UsersBAL();
                UsersModel objUsersModel = objUser.FindUser(strEmail);

                if (objUsersModel == null)
                {
                    return 1;
                }

                //Update encode string in database
                objUser.UpdateUserStatus(objUsersModel.ID, objUsersModel.Status, Common.GetSHA1HashData(objUsersModel.EmailAddress));

                //Send email to user, from XSTL
                emailModel objEmailmodel = new emailModel();
                emailBAL objEmailBAL = new emailBAL();
                List<emailModel> lstemailmodel = objEmailBAL.FindEmail("MyTP-Confirm-Reset-JAPA");

                if (lstemailmodel.Count > 0)
                {
                    DataTable DT = Common.ListToDataTable(lstemailmodel);
                    if (DT != null)
                    {

                        DataRow DR = DT.Rows[0];
                        string FileName = ConfigurationManager.AppSettings["EmailTemplatePath"] + Convert.ToString(DR["html_xslt_file"]);
                        XmlDocument xd = new XmlDocument();
                        xd.LoadXml("<tbdoc><encodestring>" + Server.UrlEncode(Common.GetSHA1HashData(objUsersModel.EmailAddress)) + "</encodestring></tbdoc>");
                        string body = RunXSLTransform(FileName, xd).ToHtmlString();

                        string FromAddress = Convert.ToString(DR["from_address"]);
                        string FromName = Convert.ToString(DR["from_name"]);
                        string subject = Convert.ToString(DR["subject"]);
                        string cc = Convert.ToString(DR["cc"]);
                        string bcc = Convert.ToString(DR["bcc"]);

                        Common.SendEmail(FromAddress, FromName, objUsersModel.EmailAddress, cc, bcc, subject, body, true);
                        return 0;
                    }
                }

                return 2;
            }
            catch
            {
                return 2;
            }
        }
Beispiel #5
0
 /// <summary>
 /// UserAlreadyExist
 /// </summary>
 /// <param name="strEmailAddress"></param>
 /// <param name="password"></param>
 /// <returns></returns>
 public UsersModel ResetEncodeStringExist(string strEncodeString)
 {
     UsersBAL objUser = new UsersBAL();
     try
     {
         UsersModel objUsersModel = objUser.ResetEncodeStringExist(strEncodeString);
         if (objUsersModel != null)
         {
             return objUsersModel;
         }
         else
         {
             return null;
         }
     }
     catch
     {
         return null;
     }
     finally
     {
         objUser = null;
     }
 }
Beispiel #6
0
        /// <summary>
        /// RegisterNewUser
        /// </summary>
        /// <param name="strEmailAddress"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public int RegisterNewUser(string strEmailAddress, string password, string encodestring)
        {
            UsersBAL objUser = new UsersBAL();
            try
            {
                UsersModel objUsersModel = new UsersModel();
                objUsersModel.EmailAddress = strEmailAddress;
                objUsersModel.Password = password;
                objUsersModel.ID = 0;
                objUsersModel.Status = "pending";
                objUsersModel.encodestring = encodestring;
                int intNewUserRegistered = objUser.RegisterNewUSer(objUsersModel);
                //Send E-mail
                //SendEmail(Common.MailType.ConfirmRegistration, strEmailAddress);

                emailModel objEmailmodel = new emailModel();
                emailBAL objEmailBAL = new emailBAL();
                List<emailModel> lstemailmodel = objEmailBAL.FindEmail("MyTP-Confirm-Register-JAPA");

                if (lstemailmodel.Count > 0)
                {
                    DataTable DT = Common.ListToDataTable(lstemailmodel);
                    if (DT != null)
                    {

                        DataRow DR = DT.Rows[0];
                        string FileName = ConfigurationManager.AppSettings["EmailTemplatePath"] + Convert.ToString(DR["html_xslt_file"]);

                        //string buffer = Common.ReadFileFromDisk(FileName, ref logger);

                        XmlDocument xd = new XmlDocument();

                        xd.LoadXml("<tbdoc><encodestring>" + Server.UrlEncode(encodestring) + "</encodestring></tbdoc>");

                        string body = RunXSLTransform(FileName, xd).ToHtmlString();

                        string FromAddress = Convert.ToString(DR["from_address"]);
                        string FromName = Convert.ToString(DR["from_name"]);
                        string subject = Convert.ToString(DR["subject"]);
                        string cc = Convert.ToString(DR["cc"]);
                        string bcc = Convert.ToString(DR["bcc"]);

                        Common.SendEmail(FromAddress, FromName, strEmailAddress, cc, bcc, subject, body, true);
                    }
                }
                return intNewUserRegistered;
            }
            catch
            {
                return 2;
            }
            finally
            {
                objUser = null;
            }
        }
Beispiel #7
0
        public ActionResult Register(FormCollection formCollection, bool captchaValid)
        {
            if (ModelState.IsValid && captchaValid)
            {
                UsersBAL objUserBAL = new UsersBAL();
                logger.Debug("Register New User");
                string userName = "", emailAddress = "", password = "", confirmPassword = "";
                foreach (string key in formCollection.Keys)
                {
                    if (key == "username")
                    {
                        userName = formCollection[key].Trim();
                    }
                    else if (key == "email")
                    {
                        emailAddress = formCollection[key].Trim();
                    }
                    else if (key == "password")
                    {
                        password = formCollection[key].Trim();
                    }
                    else if (key == "confirmpassword")
                    {
                        confirmPassword = formCollection[key].Trim();
                    }
                }

                logger.Debug("Validations check");
                if (string.IsNullOrEmpty(emailAddress) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(confirmPassword))
                {
                    return RedirectToAction("Message", "MessageDisplay", new { E = 41 });
                }

                if (password.Length < 6)
                {
                    return RedirectToAction("Message", "MessageDisplay", new { E = 46 });
                }

                if (Common.ValidateEmailAddress(emailAddress) == false)
                {
                    return RedirectToAction("Message", "MessageDisplay", new { E = 40 });
                }

                if (password != confirmPassword)
                {
                    return RedirectToAction("Message", "MessageDisplay", new { E = 36 });
                }

                logger.Debug("check user already exist or not");
                int retValue = UserAlreadyExist(emailAddress);
                if (retValue == 1)
                {
                    return RedirectToAction("Message", "MessageDisplay", new { E = 42 });
                }
                else if (retValue == 2)
                {
                    return RedirectToAction("Message", "MessageDisplay", new { E = 43 });
                }

                logger.Debug("If user not already exist then register new user");
                if (retValue == 0)
                {
                    int NewUserRegistered = RegisterNewUser(emailAddress, password, Common.GetSHA1HashData(emailAddress));

                    if (NewUserRegistered == 1)
                    {
                        return RedirectToAction("Message", "MessageDisplay", new { E = 39 });
                    }
                    else
                    {
                        return RedirectToAction("Message", "MessageDisplay", new { E = 43 });
                    }
                }
            }

            if (!captchaValid)
                return RedirectToAction("Message", "MessageDisplay", new { E = 48 });

            return View();
        }
Beispiel #8
0
 public ActionResult EmailLogin(FormCollection formCollection)
 {
     string strEMailAddress = "";
     string strPassword = "";
     foreach (string key in formCollection.Keys)
     {
         if (key == "email")
         {
             strEMailAddress = formCollection[key].Trim();
         }
         else if (key == "password")
         {
             strPassword = formCollection[key].Trim();
         }
     }
     Session["LoginEmailAddress"] = null;
     if (strEMailAddress != "" && strPassword != "" && strEMailAddress.ToLower() != "email address")
     {
         UsersBAL objUserBAL = new UsersBAL();
         List<UsersModel> lstUsersModel = objUserBAL.FindUser(strEMailAddress, strPassword);
         if (lstUsersModel != null && lstUsersModel.Count > 0)
         {
             if (lstUsersModel[0].Status == "confirm")
             {
                 Session["LoginEmailAddress"] = strEMailAddress;
                 return RedirectToAction("BookingList", "Bookings");
             }
             else
             {
                 return RedirectToAction("Message", "MessageDisplay", new { E = 50 });
             }
         }
         else
         {
             return RedirectToAction("Message", "MessageDisplay", new { E = 37 });
         }
     }
     else
     {
         return RedirectToAction("Message", "MessageDisplay", new { E = 2 });
     }
 }
Beispiel #9
0
 /// <summary>
 /// UserAlreadyExist
 /// </summary>
 /// <param name="strEmailAddress"></param>
 /// <param name="password"></param>
 /// <returns></returns>
 public int ConfirmeRegistration(string strEncodeString)
 {
     UsersBAL objUser = new UsersBAL();
     try
     {
         List<UsersModel> lstUsersModel = objUser.GetConfirmeRegistration(strEncodeString);
         if (lstUsersModel != null && lstUsersModel.Count > 0)
         {
             UpdateUserStatus(lstUsersModel[0].ID, "confirm", "");
             Session["LoginEmailAddress"] = lstUsersModel[0].EmailAddress;
             Session["LoginCurrentPassword"] = lstUsersModel[0].Password;
             return 1;
         }
         else
         {
             return 0;
         }
     }
     catch
     {
         return 2;
     }
     finally
     {
         objUser = null;
     }
 }
Beispiel #10
0
 /// <summary>
 /// ChangePassword
 /// </summary>
 /// <param name="strEmailAddress"></param>
 /// <param name="strOldPassword"></param>
 /// <param name="strNewPassword"></param>
 /// <returns></returns>
 public int ChangePasswordMethod(string strEmailAddress, string strOldPassword, string strNewPassword)
 {
     UsersBAL objUsersBAL = new UsersBAL();
     int successfullyUpdated = 0;
     try
     {
         List<UsersModel> lstUsersModel = objUsersBAL.GetPasswordByEmail(strEmailAddress);
         if (lstUsersModel != null && lstUsersModel.Count > 0)
         {
             foreach (UsersModel obj in lstUsersModel)
             {
                 if (obj.Password == strOldPassword)
                 {
                     obj.Password = strNewPassword;
                     obj.encodestring = "";
                     obj.Status = "confirm";
                     successfullyUpdated = objUsersBAL.SaveUser(obj);
                     if (successfullyUpdated == 1)
                     {
                         return 1;
                     }
                 }
                 else
                 {
                     return 0; // Either email address not registered or old password is incorrect.
                     //  return RedirectToAction("Message", "MessageDisplay", new { E = 44 });
                 }
             }
         }
         else
         {
             return 0; // Either email address not registered or old password is incorrect.
             //  return RedirectToAction("Message", "MessageDisplay", new { E = 44 });
         }
         return 0;
     }
     catch (Exception)
     {
         return 2;
     }
     finally
     {
         objUsersBAL = null;
     }
 }