PageRenderTime 59ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/AnotherStartup/App_Code/Account/Confirm.cs

#
C# | 43 lines | 34 code | 6 blank | 3 comment | 2 complexity | 501abf6e37130b3b209e7dabe4c29288 MD5 | raw file
  1. using System.Web.WebPages;
  2. using WebMatrix.WebData;
  3. namespace Account
  4. {
  5. /// <summary>
  6. /// Summary description for Confirm
  7. /// </summary>
  8. public static class Confirm
  9. {
  10. public class Error
  11. {
  12. public ErrorMessage ConfirmAccount { get; set; }
  13. public Error()
  14. {
  15. ConfirmAccount = ErrorMessage.Nil;
  16. }
  17. }
  18. public static void Init(WebPageBase web)
  19. {
  20. Error error = web.Page.Errors = new Error();
  21. web.Page.Confirmed = false;
  22. var confirmationToken = web.Request["confirmationCode"];
  23. WebSecurity.Logout();
  24. if (!confirmationToken.IsEmpty())
  25. {
  26. if (WebSecurity.ConfirmAccount(confirmationToken))
  27. {
  28. web.Page.Confirmed = true;
  29. }
  30. else
  31. {
  32. error.ConfirmAccount = web.Error("Could not confirm your registration info");
  33. }
  34. }
  35. }
  36. }
  37. }