Fixed login js
Now correctly handles failed login attempts
This commit is contained in:
parent
4330b47982
commit
daf1f8d253
@ -1,7 +1,9 @@
|
|||||||
|
var secondClick = false;
|
||||||
|
|
||||||
function storeCredentials() {
|
function storeCredentials() {
|
||||||
let usernameInput = document.getElementById('username');
|
let usernameInput = document.getElementById('username');
|
||||||
let passwordInput = document.getElementById('password');
|
let passwordInput = document.getElementById('password');
|
||||||
var jqxhr = $.ajax({
|
let jqxhr = $.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
url: `/api/chat/get/token`,
|
url: `/api/chat/get/token`,
|
||||||
headers: {
|
headers: {
|
||||||
@ -14,7 +16,7 @@ function storeCredentials() {
|
|||||||
localStorage.setItem('authToken', authToken);
|
localStorage.setItem('authToken', authToken);
|
||||||
authToken = localStorage.getItem('authToken')
|
authToken = localStorage.getItem('authToken')
|
||||||
console.log("getting header " + authToken);
|
console.log("getting header " + authToken);
|
||||||
secondClick = true;
|
// secondClick = true;
|
||||||
$('#loginForm').submit();
|
$('#loginForm').submit();
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -22,16 +24,18 @@ function storeCredentials() {
|
|||||||
jqxhr.fail(function() {
|
jqxhr.fail(function() {
|
||||||
log.error('Error retrieving auth token');
|
log.error('Error retrieving auth token');
|
||||||
alertify.error('Error retrieving auth token. Please log in again')
|
alertify.error('Error retrieving auth token. Please log in again')
|
||||||
|
secondClick = false;
|
||||||
|
// setTimeout(() => location.reload(), 2000)
|
||||||
})
|
})
|
||||||
localStorage.setItem('username', usernameInput.value);
|
localStorage.setItem('username', usernameInput.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
let secondClick = false;
|
|
||||||
$('#loginForm').on('submit', function(e) {
|
$('#loginForm').on('submit', function(e) {
|
||||||
if (!secondClick) {
|
if (!secondClick) {
|
||||||
secondClick = true;
|
secondClick = true;
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
storeCredentials();
|
storeCredentials(secondClick);
|
||||||
}
|
}
|
||||||
// else {
|
// else {
|
||||||
// secondClick = false;
|
// secondClick = false;
|
||||||
|
@ -106,10 +106,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<script>
|
|
||||||
console.log(hostAddress);
|
|
||||||
/* console.log(hostAddress2); */
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue
Block a user