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.

58 lines
2.0 KiB

  1. @{
  2. Page.Title = "Sign in";
  3. Layout = "~/themes/" + Blog.Theme + "/_Layout.cshtml";
  4. Response.Cache.SetCacheability(HttpCacheability.NoCache);
  5. if (Request.HttpMethod == "POST")
  6. {
  7. string username = Request.Form["username"];
  8. string password = Request.Form["password"];
  9. string remember = Request.Form["remember"];
  10. if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
  11. {
  12. if (FormsAuthentication.Authenticate(username, password))
  13. {
  14. FormsAuthentication.RedirectFromLoginPage(username, remember == "on");
  15. }
  16. }
  17. else if (!string.IsNullOrEmpty(Request.QueryString["signout"]))
  18. {
  19. FormsAuthentication.SignOut();
  20. Response.Redirect(Request.QueryString["ReturnUrl"], true);
  21. }
  22. }
  23. }
  24. @if (!User.Identity.IsAuthenticated)
  25. {
  26. <form action="@Request.RawUrl" method="post" role="form" class="col-md-5 col-md-offset-3" id="login">
  27. <fieldset>
  28. <h1 class="text-center">Sign in</h1>
  29. @if (Request.HttpMethod == "POST")
  30. {
  31. <p class="alert-danger">Username or password is incorrect</p>
  32. }
  33. <div class="form-group">
  34. <label for="username">Username</label>
  35. <input type="text" class="form-control" id="username" name="username" placeholder="Username" required autofocus />
  36. </div>
  37. <div class="form-group">
  38. <label for="password">Password</label>
  39. <input type="password" class="form-control" id="password" name="password" placeholder="Password" required />
  40. </div>
  41. <div class="form-group">
  42. <input type="checkbox" id="remember" name="remember" />
  43. <label for="remember">&nbsp;Remember me</label>
  44. </div>
  45. <button type="submit" class="btn btn-primary">Sign in</button>
  46. </fieldset>
  47. </form>
  48. }
  49. else
  50. {
  51. <h3>You are already signed in</h3>
  52. }