Password Reset + Bugfixes
This commit is contained in:
106
js/account.js
106
js/account.js
@@ -11,6 +11,30 @@ $(document).ready(function () {
|
||||
$("#alertMessage").hide();
|
||||
}
|
||||
|
||||
// Login
|
||||
$("#btnLogin").click(function() {
|
||||
const username = $("#username").val();
|
||||
const password = $("#password").val();
|
||||
const createdDiv = $("#accountCreated");
|
||||
const stayLoggedIn = $("#stayLoggedIn").is(":checked");
|
||||
const btn = $(this);
|
||||
|
||||
hideAlert();
|
||||
btn.prop("disabled", true);
|
||||
btn.html("Logging in… <i class=\"fa fa-spin fa-circle-notch\"></i>");
|
||||
jsCore.apiCall("/user/login", {"username": username, "password": password, "stayLoggedIn": stayLoggedIn }, function(res) {
|
||||
if (res.success) {
|
||||
document.location.reload();
|
||||
} else {
|
||||
btn.html("Login");
|
||||
btn.prop("disabled", false);
|
||||
$("#password").val("");
|
||||
createdDiv.hide();
|
||||
showAlert(res.msg);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#btnRegister").click(function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
@@ -43,4 +67,86 @@ $(document).ready(function () {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("#btnAcceptInvite").click(function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
let btn = $(this);
|
||||
let token = $("#token").val();
|
||||
let password = $("#password").val();
|
||||
let confirmPassword = $("#confirmPassword").val();
|
||||
|
||||
if(password !== confirmPassword) {
|
||||
showAlert("danger", "Your passwords did not match.");
|
||||
} else {
|
||||
let textBefore = btn.text();
|
||||
let params = { token: token, password: password, confirmPassword: confirmPassword };
|
||||
|
||||
btn.prop("disabled", true);
|
||||
btn.html("Submitting… <i class='fas fa-spin fa-spinner'></i>")
|
||||
jsCore.apiCall("user/acceptInvite", params, (res) => {
|
||||
btn.prop("disabled", false);
|
||||
btn.text(textBefore);
|
||||
if (!res.success) {
|
||||
showAlert("danger", res.msg);
|
||||
} else {
|
||||
showAlert("success", "Account successfully created. You may now login.");
|
||||
$("input").val("");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("#btnRequestPasswordReset").click(function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
let btn = $(this);
|
||||
let email = $("#email").val();
|
||||
|
||||
let textBefore = btn.text();
|
||||
btn.prop("disabled", true);
|
||||
btn.html("Submitting… <i class='fas fa-spin fa-spinner'></i>")
|
||||
jsCore.apiCall("user/requestPasswordReset", { email: email }, (res) => {
|
||||
btn.prop("disabled", false);
|
||||
btn.text(textBefore);
|
||||
if (!res.success) {
|
||||
showAlert("danger", res.msg);
|
||||
} else {
|
||||
showAlert("success", "If the e-mail address exists and is linked to a account, you will receive a password reset token.");
|
||||
$("input").val("");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#btnResetPassword").click(function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
let btn = $(this);
|
||||
let token = $("#token").val();
|
||||
let password = $("#password").val();
|
||||
let confirmPassword = $("#confirmPassword").val();
|
||||
|
||||
if(password !== confirmPassword) {
|
||||
showAlert("danger", "Your passwords did not match.");
|
||||
} else {
|
||||
let textBefore = btn.text();
|
||||
let params = { token: token, password: password, confirmPassword: confirmPassword };
|
||||
|
||||
btn.prop("disabled", true);
|
||||
btn.html("Submitting… <i class='fas fa-spin fa-spinner'></i>")
|
||||
jsCore.apiCall("user/resetPassword", params, (res) => {
|
||||
btn.prop("disabled", false);
|
||||
btn.text(textBefore);
|
||||
if (!res.success) {
|
||||
showAlert("danger", res.msg);
|
||||
} else {
|
||||
showAlert("success", "Your password was successfully changed. You may now login.");
|
||||
$("input").val("");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
28
js/admin.js
28
js/admin.js
@@ -1,28 +0,0 @@
|
||||
$(document).ready(function() {
|
||||
|
||||
// Login
|
||||
$("#username").keypress(function(e) { if(e.which === 13) $("#password").focus(); });
|
||||
$("#password").keypress(function(e) { if(e.which === 13) $("#btnLogin").click(); });
|
||||
$("#btnLogin").click(function() {
|
||||
const username = $("#username").val();
|
||||
const password = $("#password").val();
|
||||
const errorDiv = $("#loginError");
|
||||
const createdDiv = $("#accountCreated");
|
||||
const stayLoggedIn = $("#stayLoggedIn").is(":checked");
|
||||
const btn = $(this);
|
||||
|
||||
errorDiv.hide();
|
||||
btn.prop("disabled", true);
|
||||
btn.html("Logging in… <i class=\"fa fa-spin fa-circle-notch\"></i>");
|
||||
jsCore.apiCall("/user/login", {"username": username, "password": password, "stayLoggedIn": stayLoggedIn }, function(data) {
|
||||
document.location.reload();
|
||||
}, function(err) {
|
||||
btn.html("Login");
|
||||
btn.prop("disabled", false);
|
||||
$("#password").val("");
|
||||
createdDiv.hide();
|
||||
errorDiv.html(err);
|
||||
errorDiv.show();
|
||||
});
|
||||
});
|
||||
});
|
||||
6
js/admin.min.js
vendored
6
js/admin.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user