You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
3.3 KiB
JavaScript
109 lines
3.3 KiB
JavaScript
/*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
|
|
function userpasslogin(username, password) {
|
|
$.post(accounthubapi, {
|
|
key: apikey,
|
|
username: username,
|
|
password: password,
|
|
action: "auth"
|
|
}, function (resp) {
|
|
if (resp.status == "OK") {
|
|
$.post(accounthubapi, {
|
|
key: apikey,
|
|
username: username,
|
|
action: "userinfo"
|
|
}, function (resp) {
|
|
if (resp.status == "OK") {
|
|
setuser(resp.data.username);
|
|
setname(resp.data.name);
|
|
setuid(resp.data.uid);
|
|
openScreen("home");
|
|
} else {
|
|
showmsg(resp.msg, "danger");
|
|
}
|
|
}, "json");
|
|
} else {
|
|
showmsg(resp.msg, "danger");
|
|
}
|
|
}, "json");
|
|
}
|
|
|
|
function codelogin(code) {
|
|
$.post(accounthubapi, {
|
|
key: apikey,
|
|
code: code,
|
|
action: "codelogin"
|
|
}, function (resp) {
|
|
if (resp.status == "OK") {
|
|
setuser(resp.user.username);
|
|
setname(resp.user.realname);
|
|
setuid(resp.user.uid);
|
|
openScreen("home");
|
|
} else {
|
|
showmsg(resp.msg, "danger");
|
|
}
|
|
}, "json");
|
|
}
|
|
|
|
function loadQuickLogin() {
|
|
if (!isNaN(group) && group != "") {
|
|
$.post(accounthubapi, {
|
|
key: apikey,
|
|
gid: group,
|
|
action: "getusersbygroup",
|
|
get: "detail"
|
|
}, function (resp) {
|
|
if (resp.status == "OK") {
|
|
var userhtml = "";
|
|
for (var user in resp.users) {
|
|
var u = resp.users[user];
|
|
userhtml += '<div class="col-4 col-lg-3 quick-user" data-uid="' + u["uid"] + '" data-username="' + u["username"] + '" data-name="' + u["name"] + '">\n'
|
|
+ '<i class="far fa-user fa-3x"></i>\n'
|
|
+ '<br />\n'
|
|
+ u["name"] + "\n"
|
|
+ '</div>\n';
|
|
}
|
|
$("#userlist .row").html(userhtml);
|
|
$(".quick-user").click(function () {
|
|
setuser($(this).data("username"));
|
|
setname($(this).data("name"));
|
|
setuid($(this).data("uid"));
|
|
openScreen("home");
|
|
});
|
|
} else {
|
|
$("#quickaccess_tab").tab("dispose");
|
|
$("#userpass_tab").tab("show");
|
|
}
|
|
}, "json");
|
|
} else {
|
|
$("#quickaccess_tab").tab("dispose");
|
|
$("#quickaccess_tab").css("display", "none");
|
|
$("#userpass_tab").tab("show");
|
|
}
|
|
}
|
|
|
|
$("#userpass_form").submit(function (event) {
|
|
event.preventDefault();
|
|
var user = $("#username").val();
|
|
var pass = $("#password").val();
|
|
if (user != "" && pass != "") {
|
|
userpasslogin(user, pass);
|
|
}
|
|
});
|
|
|
|
$("#mobilecode_form").submit(function (event) {
|
|
event.preventDefault();
|
|
var code = $("#code").val();
|
|
if (code != "") {
|
|
codelogin(code);
|
|
}
|
|
});
|
|
|
|
$(document).ready(function () {
|
|
loadQuickLogin();
|
|
}); |