Skip to content
This repository has been archived by the owner on Oct 15, 2023. It is now read-only.

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sumuth committed Mar 14, 2016
0 parents commit e7e165f
Show file tree
Hide file tree
Showing 163 changed files with 39,413 additions and 0 deletions.
35 changes: 35 additions & 0 deletions About.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@{
Layout = "~/_SiteLayout.cshtml";
Page.Title = "About";
}

<hgroup class="title">
<h1>@Page.Title.</h1>
<h2>Your app description page.</h2>
</hgroup>

<article>
<p>
Use this area to provide additional information.
</p>

<p>
Use this area to provide additional information.
</p>

<p>
Use this area to provide additional information.
</p>
</article>

<aside>
<h3>Aside Title</h3>
<p>
Use this area to provide additional information.
</p>
<ul>
<li><a href="~/">Home</a></li>
<li><a href="~/About">About</a></li>
<li><a href="~/Contact">Contact</a></li>
</ul>
</aside>
14 changes: 14 additions & 0 deletions Account/AccountLockedOut.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@{
Layout = "~/_SiteLayout.cshtml";
Page.Title = "Account Locked";
}

<hgroup class="title">
<h1 class="error">@Page.Title.</h1>
<h2 class="error">Your account was locked out due to too many invalid log in attempts.</h2>
</hgroup>

<p>
Don't worry, the account will automatically be unlocked in 60 seconds.
Please try again after that time has passed.
</p>
38 changes: 38 additions & 0 deletions Account/Confirm.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@{
Layout = "~/_SiteLayout.cshtml";
Page.Title = "Registration Confirmation Page";

string message = "";
var confirmationToken = Request["confirmationCode"];

WebSecurity.Logout();
if (!confirmationToken.IsEmpty()) {
if (WebSecurity.ConfirmAccount(confirmationToken)) {
message = "Registration Confirmed! Click on the log in tab to log in to the site.";
} else {
message = "Could not confirm your registration info.";
}
}
}

<hgroup class="title">
<h1>@Page.Title.</h1>
<h2>Use the form below to confirm your account.</h2>
</hgroup>

@if (!message.IsEmpty()) {
<p>@message</p>
} else {
<form method="post">
<fieldset>
<legend>Confirmation Code</legend>
<ol>
<li>
<label for="confirmationCode">Confirmation code</label>
<input type="text" id="confirmationCode" name="confirmationCode" />
</li>
</ol>
<input type="submit" value="Confirm" />
</fieldset>
</form>
}
10 changes: 10 additions & 0 deletions Account/ExternalLoginFailure.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@{
// Set the layout page and page title
Layout = "~/_SiteLayout.cshtml";
Page.Title = "Login Failure";
}

<hgroup class="title">
<h1>@Page.Title.</h1>
<h2>Unsuccessful login with service.</h2>
</hgroup>
83 changes: 83 additions & 0 deletions Account/ForgotPassword.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
@* Remove this section if you are using bundling *@
@section Scripts {
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
}

@{
Layout = "~/_SiteLayout.cshtml";
Page.Title = "Forget Your Password";

bool passwordSent = false;
var resetToken = "";
var email = Request.Form["email"] ?? Request.QueryString["email"];

// Setup validation
Validation.RequireField("email", "The email address field is required.");

if (IsPost) {
AntiForgery.Validate();
// validate email
bool isValid = true;
if (Validation.IsValid()) {
if (WebSecurity.GetUserId(email) > -1 && WebSecurity.IsConfirmed(email)) {
resetToken = WebSecurity.GeneratePasswordResetToken(email); // Optionally specify an expiration date for the token
} else {
passwordSent = true; // We don't want to disclose that the user does not exist.
isValid = false;
}
}
if (isValid) {
var hostUrl = Request.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped);
var resetUrl = hostUrl + VirtualPathUtility.ToAbsolute("~/Account/PasswordReset?resetToken=" + HttpUtility.UrlEncode(resetToken));
WebMail.Send(
to: email,
subject: "Please reset your password",
body: "Use this password reset token to reset your password. The token is: " + resetToken + @". Visit <a href=""" + HttpUtility.HtmlAttributeEncode(resetUrl) + @""">" + resetUrl + "</a> to reset your password."
);
passwordSent = true;
}
}
}

<hgroup class="title">
<h1>@Page.Title.</h1>
<h2>Use the form below to reset your password.</h2>
</hgroup>

@if (!WebMail.SmtpServer.IsEmpty()) {
<p>
We will send password reset instructions to the email address associated with your account.
</p>

if (passwordSent) {
<p class="message-success">
Instructions to reset your password have been sent to the specified email address.
</p>
}

<form method="post">
@AntiForgery.GetHtml()
@Html.ValidationSummary(excludeFieldErrors: true)

<fieldset>
<legend>Password Reset Instructions Form</legend>
<ol>
<li class="email">
<label for="email" @if (!ModelState.IsValidField("email")) {<text>class="error-label"</text>}>Email address</label>
<input type="text" id="email" name="email" value="@email" disabled="@passwordSent" @Validation.For("email") />
@Html.ValidationMessage("email")
</li>
</ol>
<p class="form-actions">
<input type="submit" value="Send instructions" disabled="@passwordSent" />
</p>
</fieldset>
</form>
} else {
<p class="message-info">
Password recovery is disabled for this website because the SMTP server is
not configured correctly. Please contact the owner of this site to reset
your password.
</p>
}
104 changes: 104 additions & 0 deletions Account/Login.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
@* Remove this section if you are using bundling *@
@section Scripts {
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
}

@{
Layout = "~/_SiteLayout.cshtml";
Page.Title = "Log in";

// Initialize general page variables
var email = "";
var password = "";
var rememberMe = false;

var returnUrl = Request.QueryString["ReturnUrl"];
if (returnUrl.IsEmpty()) {
// Some external login providers always require a return URL value
returnUrl = Href("~/");
}

// Setup validation
Validation.RequireField("email", "You must specify an email address.");
Validation.RequireField("password", "You must specify a password.");
Validation.Add("password",
Validator.StringLength(
maxLength: Int32.MaxValue,
minLength: 6,
errorMessage: "Password must be at least 6 characters"));

// If this is a POST request, validate and process data
if (IsPost) {
AntiForgery.Validate();
// is this an external login request?
string provider = Request.Form["provider"];
if (!provider.IsEmpty()) {
OAuthWebSecurity.RequestAuthentication(provider, Href("~/Account/RegisterService", new { returnUrl }));
return;
} else if (Validation.IsValid()) {
email = Request.Form["email"];
password = Request.Form["password"];
rememberMe = Request.Form["rememberMe"].AsBool();

if (WebSecurity.UserExists(email) && WebSecurity.GetPasswordFailuresSinceLastSuccess(email) > 4 && WebSecurity.GetLastPasswordFailureDate(email).AddSeconds(60) > DateTime.UtcNow) {
Response.Redirect("~/Account/AccountLockedOut");
return;
}

// Attempt to log in using provided credentials
if (WebSecurity.Login(email, password, rememberMe)) {
Context.RedirectLocal(returnUrl);
return;
} else {
ModelState.AddFormError("The user name or password provided is incorrect.");
}
}
}
}

<hgroup class="title">
<h1>@Page.Title.</h1>
</hgroup>

<section id="loginForm">
<h2>Use a local account to log in.</h2>
<form method="post">
@AntiForgery.GetHtml()
@* If one or more validation errors exist, show an error *@
@Html.ValidationSummary("Log in was unsuccessful. Please correct the errors and try again.", excludeFieldErrors: true, htmlAttributes: null)

<fieldset>
<legend>Log in to Your Account</legend>
<ol>
<li class="email">
<label for="email" @if (!ModelState.IsValidField("email"))
{<text>class="error-label"</text>}>Email address</label>
<input type="text" id="email" name="email" value="@email" @Validation.For("email")/>
@* Write any user name validation errors to the page *@
@Html.ValidationMessage("email")
</li>
<li class="password">
<label for="password" @if (!ModelState.IsValidField("password")) {<text>class="error-label"</text>}>Password</label>
<input type="password" id="password" name="password" @Validation.For("password")/>
@* Write any password validation errors to the page *@
@Html.ValidationMessage("password")
</li>
<li class="remember-me">
<input type="checkbox" id="rememberMe" name="rememberMe" value="true" checked="@rememberMe" />
<label class="checkbox" for="rememberMe">Remember me?</label>
</li>
</ol>
<input type="submit" value="Log in" />
</fieldset>
</form>
<p>
<a href="~/Account/Register">Don't have a Account?</a>
<a href="~/Account/ForgotPassword">Did you forget your password?</a>
</p>
</section>

<section class="social" id="socialLoginForm">
<h2>Use another service to log in.</h2>
@RenderPage("~/Account/_ExternalLoginsList.cshtml")
</section>
17 changes: 17 additions & 0 deletions Account/Logout.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@{
WebSecurity.RequireAuthenticatedUser();

if (IsPost) {
// Verify the request was submitted by the user
AntiForgery.Validate();

// Log out of the current user context
WebSecurity.Logout();

// Redirect back to the return URL or homepage
var returnUrl = Request.QueryString["ReturnUrl"];
Context.RedirectLocal(returnUrl);
} else {
Response.Redirect("~/");
}
}
Loading

0 comments on commit e7e165f

Please sign in to comment.