Fixed login & auth
This commit is contained in:
@@ -1,13 +1,9 @@
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<!-- The user image in the navbar-->
|
||||
<!-- hidden-xs hides the username on small devices so only the image appears. -->
|
||||
</a>
|
||||
<ul style="list-style-type:none">
|
||||
<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>
|
||||
<button class="btn-default btn btn-flat" id="login-btn">Login</button>
|
||||
</div>
|
||||
<p id="msg" class="login-box-msg"></p>
|
||||
</li>
|
||||
@@ -23,19 +19,17 @@
|
||||
dataType: "json",
|
||||
type: "POST",
|
||||
success: function (data) {
|
||||
console.log(data);
|
||||
var msg = $("#msg");
|
||||
if (data.success) {
|
||||
msg.hide();
|
||||
// app.navigate("");
|
||||
window.location.reload();
|
||||
} else {
|
||||
msg.html(data.message).show();
|
||||
$("#user-menu").addClass("open");
|
||||
}
|
||||
return false;
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
alert(xhr.responseText)
|
||||
alert(xhr.status+" "+xhr.responseText)
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
@model User
|
||||
@inject IHttpContextAccessor HttpContextAccessor
|
||||
@inject IHttpContextAccessor HttpContextAccessor
|
||||
|
||||
@{
|
||||
var session = HttpContextAccessor.HttpContext.Session;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
<ul style="list-style: none">
|
||||
<li class="user-header">
|
||||
<input type="text" id="regUsername" placeholder="username" />
|
||||
<input type="password" id="regPassword" placeholder="password" />
|
||||
<input type="email" id="regEmail" placeholder="example@qualcosa.qualcosa" />
|
||||
<input type="text" id="regUsername" placeholder="Username" required />
|
||||
<input type="text" id="regName" placeholder="Name" />
|
||||
<input type="text" id="regLastname" placeholder="Lastname" />
|
||||
<input type="password" id="regPassword" placeholder="Password" required />
|
||||
<input type="email" id="regEmail" placeholder="Email" required />
|
||||
<label>Doc?</label><input type="checkbox" id="regDoctor" />
|
||||
<div>
|
||||
<button class="btn-default btn btn-flat" id="register-btn">Register</button>
|
||||
@@ -13,20 +15,26 @@
|
||||
|
||||
<script>
|
||||
$("#register-btn").on("click", function () {
|
||||
var regUsername = $("#regUsername").val();
|
||||
var regPassword = $("#regPassword").val();
|
||||
var regEmail = $("#regEmail").val();
|
||||
var regDoctor = $("#regDoctor").is(":checked");
|
||||
var username = $("#regUsername").val();
|
||||
var name = $("#regName").val();
|
||||
var lastname = $("#regLastname").val();
|
||||
var password = $("#regPassword").val();
|
||||
var email = $("#regEmail").val();
|
||||
var role = $("#regDoctor").is(":checked")? "Doctor":"User";
|
||||
|
||||
$.ajax({
|
||||
url: "/Account/_register",
|
||||
data: { Username: regUsername, Password: regPassword, Email: regEmail},
|
||||
data: {
|
||||
Username: username,
|
||||
Name: name,
|
||||
Lastname: lastname,
|
||||
Password: password,
|
||||
Email: email,
|
||||
Role: role
|
||||
},
|
||||
dataType: "json",
|
||||
type: "POST",
|
||||
success: function (data) {
|
||||
//se data.success->reload
|
||||
//se data.fail->indica errori
|
||||
|
||||
console.log(data);
|
||||
var msg = $("#msg-reg");
|
||||
if (data.success) {
|
||||
window.location.reload();
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
@inject IEnumerable<IMenuItem> Menu
|
||||
@inject IList<IMenuItem> Menu
|
||||
@inject IHttpContextAccessor HttpContextAccessor
|
||||
|
||||
@{
|
||||
string session = HttpContextAccessor.HttpContext.Session.GetString("username");
|
||||
|
||||
if (session != null) {
|
||||
Menu = new List<IMenuItem>(Menu);
|
||||
Menu.Insert(1, new MenuItem("Personal Data", "/user/" + session));
|
||||
}
|
||||
}
|
||||
<ul class="sidebar-menu" data-widget="tree">
|
||||
@foreach(var menuItem in Menu)
|
||||
@foreach (var menuItem in Menu)
|
||||
{
|
||||
switch(menuItem)
|
||||
switch (menuItem)
|
||||
{
|
||||
case MenuItem single:
|
||||
<li>
|
||||
|
||||
@@ -17,7 +17,7 @@ scratch. This page gets rid of all links and provides the needed markup only.
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>@ViewBag.Title</title>
|
||||
<title>SeniorAssistant @ViewBag.Title</title>
|
||||
<!-- Tell the browser to be responsive to screen width -->
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
|
||||
<link rel="stylesheet" href="~/AdminLTE-2.4.3/bower_components/bootstrap/dist/css/bootstrap.min.css">
|
||||
|
||||
Reference in New Issue
Block a user