set up login and register page
This commit is contained in:
@ -9,9 +9,9 @@
|
||||
<div asp-validation-summary="All"></div>
|
||||
<div class="form-group">
|
||||
<label
|
||||
asp-for="username">username</label>
|
||||
<input asp-for="username" class="form-control" required />
|
||||
<span asp-validation-for="Username" class="text-danger"></span>
|
||||
asp-for="usename">username</label>
|
||||
<input asp-for="usename" class="form-control" required />
|
||||
<span asp-validation-for="usename" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="password">password</label>
|
||||
|
||||
@ -1,56 +1,51 @@
|
||||
|
||||
@model WebApplication1.Models.user
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Register";
|
||||
}
|
||||
|
||||
<h2>Register</h2>
|
||||
<h2>Create a new user</h2>
|
||||
|
||||
<script>
|
||||
function checkPasswords() {
|
||||
var password = document.getElementById("password");
|
||||
var confirmPassword = document.getElementById("ConfirmPassword");
|
||||
var errorMessage = document.getElementById("passwordMismatch");
|
||||
@using (Html.BeginForm())
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
<div class="form-horizontal">
|
||||
<h4>user</h4>
|
||||
<hr />
|
||||
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.usename, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.usename, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.usename, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
if (password.value !== confirmPassword.value) {
|
||||
errorMessage.textContent = "Passwords do not match.";
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
errorMessage.textContent = "";
|
||||
return true;
|
||||
}
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.password, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.password, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.password, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.displayname, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.displayname, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.displayname, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<input type="submit" value="Create" class="btn btn-outline-dark" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</script>
|
||||
<form asp-action="Register" asp-controller="Account" method="post">
|
||||
<div asp-validation-summary="All"></div>
|
||||
<div class="form-group">
|
||||
<label
|
||||
asp-for="username"> username </label>
|
||||
<input asp-for="username" class="form-control" required />
|
||||
<span asp-validation-for="username" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
<label asp-for="password"> password </label>
|
||||
<input asp-for="password" id="password"
|
||||
type="password" class="form-control" required/>
|
||||
<span asp-validation-for="password" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="ConfirmPassword">Confirm Password</label>
|
||||
<input asp-for="ConfirmPassword" id="ConfirmPassword"
|
||||
type="password" class="form-control" oninput="checkPasswords()" required />
|
||||
<span asp-validation-for="ConfirmPassword" class="text-danger"></span>
|
||||
<span id="passwordMismatch" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="displayname">display name</label>
|
||||
|
||||
<input asp-for="displayname" class="form-control" required />
|
||||
<span asp-validation-for="displayname" class="text-danger" ></span>
|
||||
</div>
|
||||
<br />
|
||||
<button type="submit" class="btn btn-primary">Register</button>
|
||||
</form>
|
||||
|
||||
<div>
|
||||
@Html.ActionLink("Back to List", "Index")
|
||||
</div>
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
<li>@Html.ActionLink("Home", "Index", "Home", new { area = "" }, new { @class = "nav-link" })</li>
|
||||
<li>@Html.ActionLink("About", "About", "Home", new { area = "" }, new { @class = "nav-link" })</li>
|
||||
<li>@Html.ActionLink("Contact", "Contact", "Home", new { area = "" }, new { @class = "nav-link" })</li>
|
||||
<li>@Html.ActionLink("Login", "Login", "Account", new { area = "" }, new { @class = "nav-link" })</li>
|
||||
<li>@Html.ActionLink("Register", "Register", "Account", new { area = "" }, new { @class = "nav-link" })</li>
|
||||
<li>@Html.ActionLink("Login", "Login", "users", new { area = "" }, new { @class = "nav-link" })</li>
|
||||
<li>@Html.ActionLink("Register", "Register", "users", new { area = "" }, new { @class = "nav-link" })</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Latest";
|
||||
}
|
||||
|
||||
<h2>Latest</h2>
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
|
||||
@{
|
||||
ViewBag.Title = "index";
|
||||
}
|
||||
|
||||
<h2>Whats good?</h2>
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
|
||||
@{
|
||||
ViewBag.Title = "submit";
|
||||
}
|
||||
|
||||
<h2>submit a new article</h2>
|
||||
<h3>what's new?'</h3>
|
||||
<form>
|
||||
title: <input /> <br /><br />
|
||||
link: <input /> <br /><br />
|
||||
summary: <input /> <br /><br />
|
||||
content: <textarea> </textarea> <br /><br />
|
||||
<input type="submit" />
|
||||
</form>
|
||||
48
Views/users/Delete.cshtml
Normal file
48
Views/users/Delete.cshtml
Normal file
@ -0,0 +1,48 @@
|
||||
@model WebApplication1.Models.user
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Delete";
|
||||
}
|
||||
|
||||
<h2>Delete</h2>
|
||||
|
||||
<h3>Are you sure you want to delete this?</h3>
|
||||
<div>
|
||||
<h4>user</h4>
|
||||
<hr />
|
||||
<dl class="dl-horizontal">
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.usename)
|
||||
</dt>
|
||||
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.usename)
|
||||
</dd>
|
||||
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.password)
|
||||
</dt>
|
||||
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.password)
|
||||
</dd>
|
||||
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.displayname)
|
||||
</dt>
|
||||
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.displayname)
|
||||
</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
@using (Html.BeginForm()) {
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
<div class="form-actions no-color">
|
||||
<input type="submit" value="Delete" class="btn btn-default" /> |
|
||||
@Html.ActionLink("Back to List", "Index")
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
42
Views/users/Details.cshtml
Normal file
42
Views/users/Details.cshtml
Normal file
@ -0,0 +1,42 @@
|
||||
@model WebApplication1.Models.user
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Details";
|
||||
}
|
||||
|
||||
<h2>Details</h2>
|
||||
|
||||
<div>
|
||||
<h4>user</h4>
|
||||
<hr />
|
||||
<dl class="dl-horizontal">
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.usename)
|
||||
</dt>
|
||||
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.usename)
|
||||
</dd>
|
||||
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.password)
|
||||
</dt>
|
||||
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.password)
|
||||
</dd>
|
||||
|
||||
<dt>
|
||||
@Html.DisplayNameFor(model => model.displayname)
|
||||
</dt>
|
||||
|
||||
<dd>
|
||||
@Html.DisplayFor(model => model.displayname)
|
||||
</dd>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<p>
|
||||
@Html.ActionLink("Edit", "Edit", new { id = Model.ID }) |
|
||||
@Html.ActionLink("Back to List", "Index")
|
||||
</p>
|
||||
53
Views/users/Edit.cshtml
Normal file
53
Views/users/Edit.cshtml
Normal file
@ -0,0 +1,53 @@
|
||||
@model WebApplication1.Models.user
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Edit";
|
||||
}
|
||||
|
||||
<h2>Edit</h2>
|
||||
|
||||
@using (Html.BeginForm())
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
<div class="form-horizontal">
|
||||
<h4>user</h4>
|
||||
<hr />
|
||||
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
|
||||
@Html.HiddenFor(model => model.ID)
|
||||
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.usename, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.usename, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.usename, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.password, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.password, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.password, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.displayname, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.displayname, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.displayname, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<input type="submit" value="Save" class="btn btn-default" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div>
|
||||
@Html.ActionLink("Back to List", "Index")
|
||||
</div>
|
||||
45
Views/users/Index.cshtml
Normal file
45
Views/users/Index.cshtml
Normal file
@ -0,0 +1,45 @@
|
||||
@model IEnumerable<WebApplication1.Models.user>
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Index";
|
||||
}
|
||||
|
||||
<h2>Index</h2>
|
||||
|
||||
<p>
|
||||
@Html.ActionLink("Create New", "Create")
|
||||
</p>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.usename)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.password)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.displayname)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
@foreach (var item in Model) {
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.usename)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.password)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.displayname)
|
||||
</td>
|
||||
<td>
|
||||
@Html.ActionLink("Edit", "Edit", new { id=item.ID }) |
|
||||
@Html.ActionLink("Details", "Details", new { id=item.ID }) |
|
||||
@Html.ActionLink("Delete", "Delete", new { id=item.ID })
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
</table>
|
||||
43
Views/users/Login.cshtml
Normal file
43
Views/users/Login.cshtml
Normal file
@ -0,0 +1,43 @@
|
||||
@model WebApplication1.Models.user
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Login";
|
||||
}
|
||||
|
||||
<h2>Login</h2>
|
||||
|
||||
@using (Html.BeginForm())
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
<div class="form-horizontal">
|
||||
<h4>user</h4>
|
||||
<hr />
|
||||
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.usename, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.usename, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.usename, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.password, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.password, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.password, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<input type="submit" value="Login!" class="btn btn-outline-dark" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div>
|
||||
@Html.ActionLink("Back to List", "Index")
|
||||
</div>
|
||||
51
Views/users/Register.cshtml
Normal file
51
Views/users/Register.cshtml
Normal file
@ -0,0 +1,51 @@
|
||||
@model WebApplication1.Models.user
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Register";
|
||||
}
|
||||
|
||||
<h2>Create a new user</h2>
|
||||
|
||||
@using (Html.BeginForm())
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
<div class="form-horizontal">
|
||||
<h4>user</h4>
|
||||
<hr />
|
||||
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.usename, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.usename, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.usename, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.password, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.password, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.password, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.displayname, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.displayname, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.displayname, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<input type="submit" value="Create" class="btn btn-outline-dark" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div>
|
||||
@Html.ActionLink("Back to List", "Index")
|
||||
</div>
|
||||
Reference in New Issue
Block a user