PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/BaliEnterpriseSystems/BaliEnterpriseSystems/ChangePassword.aspx.cs

https://github.com/sirivedula/BEST
C# | 40 lines | 36 code | 4 blank | 0 comment | 4 complexity | f7c2da3f305924dc8f28552f3b2786d2 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. namespace BaliEnterpriseSystems
  8. {
  9. public partial class ChangePassword : System.Web.UI.Page
  10. {
  11. protected void Page_LoadComplete(object sender, EventArgs e)
  12. {
  13. if (HttpContext.Current.Session["CurrentUser"] == null)
  14. {
  15. Response.Redirect("Logout.aspx");
  16. }
  17. if (Request.Form.Count > 0)
  18. {
  19. string newPassword = Request.Form["newpassword"];
  20. var cUser = Utils.User;
  21. cUser.BestUser.password = Utils.GetMD5Hash(newPassword);
  22. cUser.BestUser.initialPassword = false;
  23. cUser.BestUser.passwordExpiration = DateTime.Today.AddDays(365);
  24. cUser.BestUser.overrideEdit = true;
  25. if (!cUser.BestUser.CurrentRow.Save())
  26. {
  27. this.ChangePasswordMessage.Text = "<div class=\"err\">There was a problem changing your password. Please try again.</div>";
  28. }
  29. else
  30. {
  31. Response.Redirect("BestWelcome.aspx");
  32. }
  33. }
  34. }
  35. }
  36. }