PageRenderTime 40ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/BlogEngine/BlogEngine.NET/Account/login.aspx.cs

#
C# | 70 lines | 50 code | 11 blank | 9 comment | 12 complexity | 2b21926ff9e820cd98d0cc65cb0c2561 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause
  1. namespace Account
  2. {
  3. using System;
  4. using System.Web;
  5. using System.Web.Security;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. using BlogEngine.Core;
  9. using Resources;
  10. /// <summary>
  11. /// The login.
  12. /// </summary>
  13. public partial class Login : System.Web.UI.Page
  14. {
  15. #region Methods
  16. /// <summary>
  17. /// Handles the Load event of the Page control.
  18. /// </summary>
  19. /// <param name="sender">The source of the event.</param>
  20. /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
  21. protected void Page_Load(object sender, EventArgs e)
  22. {
  23. HyperLink linkForgotPassword = (HyperLink)LoginUser.FindControl("linkForgotPassword");
  24. if (linkForgotPassword != null)
  25. {
  26. linkForgotPassword.NavigateUrl = Utils.RelativeWebRoot + "Account/password-retrieval.aspx";
  27. }
  28. this.RegisterHyperLink.NavigateUrl = Utils.RelativeWebRoot + "Account/register.aspx?ReturnUrl=" +
  29. HttpUtility.UrlEncode(this.Request.QueryString["ReturnUrl"]);
  30. this.RegisterHyperLink.Text = labels.createNow;
  31. ((PlaceHolder)LoginUser.FindControl("phResetPassword")).Visible = BlogSettings.Instance.EnablePasswordReset;
  32. if (this.Request.QueryString.ToString() == "logoff")
  33. {
  34. Security.SignOut();
  35. if (this.Request.UrlReferrer != null && this.Request.UrlReferrer != this.Request.Url && this.Request.UrlReferrer.LocalPath.IndexOf("/admin/", StringComparison.OrdinalIgnoreCase) == -1)
  36. {
  37. this.Response.Redirect(this.Request.UrlReferrer.ToString(), true);
  38. }
  39. else
  40. {
  41. this.Response.Redirect(BlogEngine.Core.Utils.RelativeWebRoot);
  42. }
  43. return;
  44. }
  45. if (!this.Page.IsPostBack || Security.IsAuthenticated)
  46. {
  47. return;
  48. }
  49. this.Master.SetStatus("warning", Resources.labels.loginFailed);
  50. }
  51. protected void LoginUser_OnAuthenticate(object sender, AuthenticateEventArgs e)
  52. {
  53. // always set to false
  54. e.Authenticated = false;
  55. Security.AuthenticateUser(LoginUser.UserName, LoginUser.Password, LoginUser.RememberMeSet);
  56. }
  57. #endregion
  58. }
  59. }