Use AJAX for login
This commit is contained in:
parent
b2ed65788e
commit
a122e5db0c
@ -1,14 +1,38 @@
|
|||||||
<html>
|
<html>
|
||||||
<head><title>Login</title>
|
<head>
|
||||||
|
<title>Login</title>
|
||||||
|
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
|
||||||
|
<script src="http://malsup.github.com/jquery.form.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// wait for the DOM to be loaded
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#invalidCredentials').hide();
|
||||||
|
// bind 'myForm' and provide a simple callback function
|
||||||
|
$('#loginForm').ajaxForm({
|
||||||
|
success: function() {
|
||||||
|
window.location.href = "/api/v1/restricted";
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
$('#invalidCredentials').show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<form action="/api/v1/login?target=/" method="POST">
|
<form id="loginForm" action="/api/v1/login?target=/" method="POST">
|
||||||
<label for="username">User</label>
|
<label for="username">User</label>
|
||||||
<input type="text" name="username" /><br />
|
<input type="text" name="username" /><br />
|
||||||
|
|
||||||
<label for="password">Password</label>
|
<label for="password">Password</label>
|
||||||
<input type="password" name="password" /><br />
|
<input type="password" name="password" /><br />
|
||||||
|
|
||||||
<input type="submit">Login</form>
|
<div id="invalidCredentials">
|
||||||
|
The entered credentials are invalid
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input type="submit" value="Login"/>
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
x
Reference in New Issue
Block a user