コード例 #1
0
        public ActionResult ForgotPassword(ChangePasswordModel objChangePasswordModel)
        {
            UtilityWeb objUtilityWeb = new UtilityWeb();

            try
            {
                UserLogin     objUserLogin     = new RepidShare.Entities.UserLogin();
                EmailTemplate objEmailTemplate = new EmailTemplate();
                objUserLogin.Email = objChangePasswordModel.EmailID;
                serviceResponse    = objUtilityWeb.PostAsJsonAsync(WebApiURL.UserLogin + "/ForgotPassword", objUserLogin);
                objUserLogin       = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <UserLogin>().Result : null;
                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                message.To.Add(objChangePasswordModel.EmailID);
                serviceResponse  = objUtilityWeb.GetAsync(WebApiURL.Email + "/GetEmailSettingByEmailID?EmailID=" + Convert.ToInt32(RepidShare.Utility.CommonUtils.EmailType.ForgotPassword));
                objEmailTemplate = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <EmailTemplate>().Result : null;
                message.Subject  = objEmailTemplate.EmailSubject;
                //"Forgot Password By Papeleslegales.com";
                message.Body = objEmailTemplate.Content + "<br/>Your Password According to our records is: , <h3>" + objUserLogin.Password + "</h3>";;
                //"<p>Your password has been reset, <h3> " + objUserLogin.UserName + "</h3></p>  </br><p> According to our records, you have requested that your password be reset. Your new password is:<h3>" + objUserLogin.Password + "<h3/></p> </br></br><p>If you have any questions or trouble logging on please contact a site administrator.</p><br/><br/><br/>Thank you!";
                message.IsBodyHtml = true;

                if (objUserLogin.ErrorCode == 0)
                {
                    if (RepidShare.Utility.CommonUtils.Send(message))
                    {
                        // Session["SuccessMessage"] = "E-Mail Sent Successfully!";
                        objChangePasswordModel.Message = "<p style='color:green;'>Your Passowrd has been sent to your account. for login click <a href='http://localhost:49339/User/Login'> Login <a></p>";
                    }
                }
                else
                {
                    //  Session["ErrorMessage"] = "Oppps, Your Account is not valid!!!";
                    objChangePasswordModel.Message = "<p style='color:red;'>Oppps, Your Account is not valid!!!</p>";
                }

                // return RedirectToAction("Login", "User");
                return(View("ForgotPassword", objChangePasswordModel));
            }
            catch (Exception ex)
            {
                //Session["ExceptionMsg"] = objCommonUtils.ErrorLog(createdBy.ToString(), "User", "ForgotPassword Post", ex);
            }

            return(View("ForgotPassword", objChangePasswordModel));
        }
コード例 #2
0
        public ActionResult ChangePassword(ChangePasswordModel objChangePasswordModel)
        {
            try
            {
                UtilityWeb objUtilityWeb = new UtilityWeb();
                UserLogin  objUserLogin  = new RepidShare.Entities.UserLogin();
                objUserLogin.UserID   = LoggedInUserID;
                objUserLogin.Password = objChangePasswordModel.ConfirmPassword;
                objUserLogin.RoleID   = RoleID;

                serviceResponse = objUtilityWeb.PostAsJsonAsync(WebApiURL.UserLogin + "/ChangePassword", objUserLogin);
                objUserLogin    = serviceResponse.StatusCode == HttpStatusCode.OK ? serviceResponse.Content.ReadAsAsync <UserLogin>().Result : null;

                if (objUserLogin == null)
                {
                    //Set Error msg
                    objChangePasswordModel.Message     = "Please contact with Admin";
                    objChangePasswordModel.MessageType = RepidShare.Utility.CommonUtils.MessageType.Error.ToString().ToLower();
                }

                if (objUserLogin.ErrorCode > 0)
                {
                    objChangePasswordModel.Message     = "Invalid UserName Or Password";
                    objChangePasswordModel.MessageType = RepidShare.Utility.CommonUtils.MessageType.Error.ToString().ToLower();
                }

                if (objUserLogin.ErrorCode == 0)
                {
                    objChangePasswordModel.Message     = "Password changed successfully.";
                    objChangePasswordModel.MessageType = RepidShare.Utility.CommonUtils.MessageType.Success.ToString().ToLower();
                }
                return(View(objChangePasswordModel));
            }
            catch (Exception ex)
            {
                //  Session["ExceptionMsg"] = objCommonUtils.ErrorLog(createdBy.ToString(), "User", "ChangePassword Post", ex);
            }

            return(View(objChangePasswordModel));
        }