You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
2.3 KiB

4 years ago
  1. using Business.Account;
  2. using Business.Configuration;
  3. using Common.Helper;
  4. using Common.Model;
  5. using Common.Model.Account;
  6. using Newtonsoft.Json;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Web;
  11. using System.Web.UI;
  12. using System.Web.UI.WebControls;
  13. namespace JMEAgentSystem.WebPages.Account
  14. {
  15. public partial class ForceChangePassword : System.Web.UI.Page
  16. {
  17. private readonly IAccountServices _accountServices = AutoFacContainer.Resolve<IAccountServices>();
  18. protected void Page_Load(object sender, EventArgs e)
  19. {
  20. var methodName = GetStatic.ReadFormData("MethodName", "");
  21. if (methodName == "ChangePassword")
  22. Change_Password();
  23. }
  24. private void Change_Password()
  25. {
  26. PasswordChangeModel model = new PasswordChangeModel()
  27. {
  28. ReferralCode = GetStatic.GetUser(),
  29. Password = GetStatic.ReadFormData("Password", ""),
  30. NewPassword = GetStatic.ReadFormData("NewPassword", ""),
  31. ConformNewPassword = GetStatic.ReadFormData("ConformNewPassword", ""),
  32. IpAddress = GetStatic.GetIpAddress(Request),
  33. UserDetails = GetStatic.GetUserInfo(Request),
  34. IsForceChangePassword = GetStatic.ReadFormData("changeType", "")
  35. };
  36. DbResponse result;
  37. if (model.Password != model.NewPassword)
  38. result = new DbResponse()
  39. {
  40. ResponseCode = "1",
  41. Msg = "Old Password And New Password Can't Be Same!"
  42. };
  43. if (model.NewPassword != model.ConformNewPassword)
  44. result = new DbResponse()
  45. {
  46. ResponseCode = "1",
  47. Msg = "New Password And Conform New Password Must Be Match!"
  48. };
  49. else
  50. result = _accountServices.ChangePassword(model);
  51. if (result.ResponseCode == "0")
  52. GetStatic.WriteSession("isForceChangePassword", "False");
  53. Response.ContentType = "text/plain";
  54. string json = JsonConvert.SerializeObject(result);
  55. Response.Write(json);
  56. Response.End();
  57. }
  58. }
  59. }