Files
upo-senior-assistant/SeniorAssistant/Views/Shared/Register.cshtml
Giacomo 1739314aef Migliorato login/logout
Ma forse si passa alla versione con modelli per login e register in futuro
2018-12-04 16:40:24 +01:00

45 lines
1.5 KiB
Plaintext

<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>