Migliorato login/logout

Ma forse si passa alla versione con modelli per login e register in futuro
This commit is contained in:
2018-12-04 16:40:24 +01:00
parent cfe35f4d8a
commit 1739314aef
11 changed files with 194 additions and 235 deletions

View File

@@ -0,0 +1,45 @@
<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. -->
<span id="user-name" class="hidden-xs">Register</span>
</a>
<ul class="dropdown-menu">
<li class="user-header">
<input type="email" id="mail" placeholder="E-mail"/>
<input type="text" id="username" placeholder="username" />
<input type="password" id="password" placeholder="password" />
<div>
<button class="btn-default btn btn-flat" id="register-btn">Register</button>
</div>
<p id="msg" class="login-box-msg"></p>
</li>
</ul>
<script>
$("#register-btn").on("click", function () {
var userName = $("#username").val();
var password = $("#password").val();
var mail = $("#mail").val();
$.ajax({
url: "/Account/_register",
data: { UserName: userName, Password: password, Email: mail},
dataType: "json",
type: "POST",
success: function (data) {
console.log(data);
var msg = $("#msg");
if (data.success) {
msg.hide();
} else {
msg.html(data.message).show();
$("#user-menu").addClass("open");
}
},
error: function (xhr, status, error) {
alert(xhr.responseText)
}
})
});
</script>