Fixes
- Added forgot option - added modify user - moved login and register
This commit is contained in:
29
SeniorAssistant/Views/Home/Forgot.cshtml
Normal file
29
SeniorAssistant/Views/Home/Forgot.cshtml
Normal file
@@ -0,0 +1,29 @@
|
||||
@model Forgot
|
||||
|
||||
<p>Se indovini la risposta allora verrai loggato. Li poi potrai modificare la password.</p>
|
||||
<label>Domanda di sicurezza: </label><p>@Model.Question</p>
|
||||
<label>Risposta: </label><input id="answer" type="text" placeholder="Risposta"/>
|
||||
<p id="error"></p>
|
||||
<button id="send-answ">Invia</button>
|
||||
|
||||
<script>
|
||||
$("#send-answ").on("click", function () {
|
||||
var answer = $("#answer").val();
|
||||
|
||||
$.ajax({
|
||||
url: "/Account/_checkQuestion",
|
||||
dataType: "json",
|
||||
type: "POST",
|
||||
data: {
|
||||
Username: "@Model.Username",
|
||||
Answer: answer
|
||||
},
|
||||
success: function (data) {
|
||||
if (data.success)
|
||||
window.location.reload();
|
||||
else
|
||||
$("#error").html(data.message);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
56
SeniorAssistant/Views/Home/Login.cshtml
Normal file
56
SeniorAssistant/Views/Home/Login.cshtml
Normal file
@@ -0,0 +1,56 @@
|
||||
@model string
|
||||
|
||||
<div class="content">
|
||||
@if (Model != null)
|
||||
{
|
||||
<p class="text-red box-title">Per poter accedere alla pagina [@Model] e' necessario essere loggati</p>
|
||||
}
|
||||
<ul style="list-style-type:none">
|
||||
<li class="user-header">
|
||||
<input type="text" id="username" placeholder="username" />
|
||||
<input type="password" id="password" placeholder="password" />
|
||||
<div>
|
||||
<button class="btn-default btn btn-flat" id="login-btn">Login</button>
|
||||
</div>
|
||||
<p id="msg" class="login-box-msg"></p>
|
||||
</li>
|
||||
</ul>
|
||||
<button id="forgot">Dimanticato la passw?</button>
|
||||
<form id="div-forgot" style="display:none" action="/Forgot" method="get">
|
||||
<label>Username</label><input name="username" type="text" />
|
||||
<input type="submit" id="ok-forgot" value="OK" />
|
||||
</form>
|
||||
|
||||
@Html.ActionLink("Oppure registrati", "Register")
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$("#forgot").on("click", function () {
|
||||
$("#div-forgot").css("display", "block");
|
||||
});
|
||||
|
||||
$("#ok-forgot").on("click", function () {
|
||||
$("#div-forgot").css("display", "block");
|
||||
});
|
||||
|
||||
$("#login-btn").on("click", function () {
|
||||
var username = $("#username").val();
|
||||
var password = $("#password").val();
|
||||
$.ajax({
|
||||
url: "/Account/_login",
|
||||
data: { Username: username, Password: password },
|
||||
dataType: "json",
|
||||
type: "POST",
|
||||
success: function (data) {
|
||||
var msg = $("#msg");
|
||||
if (data.success) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
msg.html(data.message).show();
|
||||
$("#user-menu").addClass("open");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
})
|
||||
});
|
||||
</script>
|
||||
@@ -6,6 +6,8 @@
|
||||
<input type="password" id="regPassword" placeholder="Password" required />
|
||||
<input type="email" id="regEmail" placeholder="Email" required />
|
||||
<input type="text" id="regDoctor" placeholder="Doctor only (543210)" />
|
||||
<input type="text" id="passwQues" placeholder="Domanda di sicurezza" required />
|
||||
<input type="text" id="passwAnsw" placeholder="Risposta di sicurezza" required />
|
||||
<div>
|
||||
<button class="btn-default btn btn-flat" id="register-btn">Register</button>
|
||||
</div>
|
||||
@@ -13,6 +15,8 @@
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@Html.ActionLink("Oppure fai il login", "Login")
|
||||
|
||||
<script>
|
||||
$("#register-btn").on("click", function () {
|
||||
var username = $("#regUsername").val();
|
||||
@@ -22,6 +26,9 @@
|
||||
var email = $("#regEmail").val();
|
||||
var code = $("#regDoctor").val();
|
||||
|
||||
var quest = $("#passwQues").val();
|
||||
var answ = $("#passwAnsw").val();
|
||||
|
||||
$.ajax({
|
||||
url: "/Account/_register",
|
||||
data: {
|
||||
@@ -32,6 +39,10 @@
|
||||
Lastname: lastname,
|
||||
Password: password,
|
||||
Email: email
|
||||
},
|
||||
Forgot: {
|
||||
Question: quest,
|
||||
Answer: answ
|
||||
}
|
||||
},
|
||||
dataType: "json",
|
||||
@@ -132,9 +132,6 @@ else
|
||||
&& Object.keys(sleep).length == 0)
|
||||
$("#chart-data").html("Nessun dato");
|
||||
else {
|
||||
/* se checked #show-table allora crea dati come data.cshtml for () {
|
||||
allData.push({"time"});
|
||||
}*/
|
||||
$("#chart-data").html("");
|
||||
console.log(heartbeat[0].time);
|
||||
console.log("min = " +new Date(heartbeat[0].time).getTime());
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
@{
|
||||
var controller = ViewContext.RouteData.Values["Controller"];
|
||||
var action = ViewContext.RouteData.Values["Action"];
|
||||
var controller = ViewContext.RouteData.Values["Controller"].ToString();
|
||||
var action = ViewContext.RouteData.Values["Action"].ToString();
|
||||
}
|
||||
|
||||
<div class="breadcrumb">
|
||||
@Html.ActionLink("Home", "Index", "Home")
|
||||
@if (controller.ToString() != "Home")
|
||||
@if (controller != "Home")
|
||||
{
|
||||
@:> @Html.ActionLink(controller.ToString(), "Index", controller.ToString())
|
||||
@:> @Html.ActionLink(controller, "Index", controller)
|
||||
}
|
||||
@if (action.ToString() != "Index")
|
||||
@if (action != "Index")
|
||||
{
|
||||
@:> @Html.ActionLink(action.ToString(), action.ToString(), controller.ToString())
|
||||
@:> @Html.ActionLink(action, action, controller)
|
||||
}
|
||||
|
||||
</div>
|
||||
@@ -1,33 +0,0 @@
|
||||
<ul style="list-style-type:none">
|
||||
<li class="user-header">
|
||||
<input type="text" id="username" placeholder="username" />
|
||||
<input type="password" id="password" placeholder="password" />
|
||||
<div>
|
||||
<button class="btn-default btn btn-flat" id="login-btn">Login</button>
|
||||
</div>
|
||||
<p id="msg" class="login-box-msg"></p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<script>
|
||||
$("#login-btn").on("click", function () {
|
||||
var username = $("#username").val();
|
||||
var password = $("#password").val();
|
||||
$.ajax({
|
||||
url: "/Account/_login",
|
||||
data: { Username: username, Password: password },
|
||||
dataType: "json",
|
||||
type: "POST",
|
||||
success: function (data) {
|
||||
var msg = $("#msg");
|
||||
if (data.success) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
msg.html(data.message).show();
|
||||
$("#user-menu").addClass("open");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
})
|
||||
});
|
||||
</script>
|
||||
@@ -5,10 +5,12 @@
|
||||
var session = HttpContextAccessor.HttpContext.Session;
|
||||
string search = HttpContextAccessor.HttpContext.Request.Query["q"];
|
||||
string username = session.GetString("username");
|
||||
|
||||
|
||||
if (username != null)
|
||||
{
|
||||
var isDoc = session.GetString("role").Equals("doctor");
|
||||
var MaxPatients = 30;
|
||||
var Menu = new List<IMenuItem>();
|
||||
Menu.Add(new MenuItem("Profilo", "/"));
|
||||
Menu.Add(new MenuItem("Dati personali", "/user/" + username));
|
||||
@@ -19,7 +21,18 @@
|
||||
where p.Doctor.Equals(username)
|
||||
join u in db.Users on p.Username equals u.Username
|
||||
select new { Username = p.Username, Name = u.Name + " " + u.LastName }).ToArray();
|
||||
var sub = new SubMenu() { Text = "Pazienti", Items = new List<MenuItem>() };
|
||||
|
||||
if(search != null)
|
||||
{
|
||||
patients = (from p in patients
|
||||
where p.Name.StartsWith(search)
|
||||
select p).ToArray();
|
||||
}
|
||||
|
||||
patients.Take(MaxPatients);
|
||||
|
||||
var num = patients.Count();
|
||||
var sub = new SubMenu() { Text = num + " pazienti link rapido", Items = new List<MenuItem>() };
|
||||
foreach (var p in patients)
|
||||
{
|
||||
sub.Items.Add(new MenuItem(p.Name, "/user/" + p.Username));
|
||||
@@ -32,7 +45,10 @@
|
||||
var patient = (from p in db.Patients
|
||||
where p.Username.Equals(username)
|
||||
select p).FirstOrDefault();
|
||||
Menu.Add(new MenuItem("Invia un messaggio al dottore", "/Message/" + patient.Doctor));
|
||||
if (patient != null)
|
||||
{
|
||||
Menu.Add(new MenuItem("Invia un messaggio al dottore", "/Message/" + patient.Doctor));
|
||||
}
|
||||
}
|
||||
<aside class="main-sidebar">
|
||||
<!-- sidebar: style can be found in sidebar.less -->
|
||||
|
||||
Reference in New Issue
Block a user