|
@@ -1204,7 +1204,7 @@
|
|
|
</div>
|
|
|
<div class="ui divider"></div>
|
|
|
<div class="item" style="padding-left: 8px;">
|
|
|
- <div class="ui small items" style="margin-bottom: 0; width: 100%;">
|
|
|
+ <div id="alternativeAccountList" class="ui small items" style="margin-bottom: 0; width: 100%;">
|
|
|
<div class="alternativeUsableAccount item" style="padding-left: 0px;">
|
|
|
<div class="ui mini image">
|
|
|
<img class="accountIcon" src="img/desktop/system_icon/user.svg">
|
|
@@ -1667,7 +1667,7 @@
|
|
|
alert(data.error);
|
|
|
}else{
|
|
|
userInfo = data;
|
|
|
-
|
|
|
+ listAllStoredAccounts();
|
|
|
|
|
|
//Update the user tag
|
|
|
$("#username").text(userInfo.Username);
|
|
@@ -7242,6 +7242,107 @@
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ /*
|
|
|
+ Alternative account manager
|
|
|
+ */
|
|
|
+ function getBrowserAccountPoolUUID(){
|
|
|
+ return localStorage.getItem("ao_acc");
|
|
|
+ }
|
|
|
+ function listAllStoredAccounts(){
|
|
|
+ $("#alternativeAccountList").empty();
|
|
|
+ if (getBrowserAccountPoolUUID() == undefined){
|
|
|
+ //Empty or no stored accounts
|
|
|
+ $("#alternativeAccountList").append(`<div class="ui message">
|
|
|
+ <i class="ui green check circle icon"></i> No other account stored on this browser
|
|
|
+ </div>`);
|
|
|
+ $("#signoutAllButton").addClass('disabled');
|
|
|
+ return;
|
|
|
+ }else{
|
|
|
+ //Request server side for the account pool
|
|
|
+ $.get("system/auth/u/list?pid=" + getBrowserAccountPoolUUID(), function(data){
|
|
|
+ if (data.error != undefined){
|
|
|
+ $("#alternativeAccountList").append(`<div class="ui message">
|
|
|
+ <i class="ui green check circle icon"></i> No other account stored on this browser
|
|
|
+ </div>`);
|
|
|
+ }else{
|
|
|
+ if (data.length > 0){
|
|
|
+ data.forEach(function(account){
|
|
|
+ if (account.Username == userInfo.Username){
|
|
|
+ //Skip
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ $.get("system/desktop/user?target=" + account.Username, function(data){
|
|
|
+ let userIcon = data.UserIcon;
|
|
|
+ if (userIcon == ""){
|
|
|
+ userIcon = "img/desktop/system_icon/user.svg"
|
|
|
+ }
|
|
|
+ $("#alternativeAccountList").append(`
|
|
|
+ <div class="alternativeAccount ${account.IsExpired?"expired":""}" acname="${account.Username}" onclick="switchAccount(this);" style="margin-top: 0.4em;">
|
|
|
+ <div class="ui header">
|
|
|
+ <img class="usericon" src="${userIcon}">
|
|
|
+ <div class="content" style="font-size: 95% !important;">
|
|
|
+ <span class="username">${account.Username}</span> ${(data.IsAdmin)?'<i style="margin-left: 0.4em; color: rgb(38, 50, 56);" title="Admin" class="small shield alternate icon themed text"></i>':""}
|
|
|
+ <div class="sub header usergroup">${!account.IsExpired?"<i class='ui green check circle icon' style='margin-right: 0px;'></i> Session Valid":"<i class='ui red times circle icon' style='margin-right: 0px;'></i> Session Expired"}</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ $("#signoutAllButton").removeClass('disabled');
|
|
|
+ }else{
|
|
|
+ $("#signoutAllButton").addClass('disabled');
|
|
|
+ $("#alternativeAccountList").append(`<div class="ui message">
|
|
|
+ <i class="ui green check circle icon"></i> No other account stored on this browser
|
|
|
+ </div>`);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function switchAccount(object){
|
|
|
+ alert("WIP")
|
|
|
+ return;
|
|
|
+ let targetUsername = $(object).attr("acname");
|
|
|
+ if (targetUsername == undefined || targetUsername == ""){
|
|
|
+ console.log("Unable to load username from element")
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //Check if it is expired
|
|
|
+ if ($(object).hasClass("expired")){
|
|
|
+ $("#username").val(targetUsername);
|
|
|
+ $("#restoreSessionMessage").show();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ $.ajax({
|
|
|
+ url: "system/auth/u/switch",
|
|
|
+ data: {
|
|
|
+ "username": targetUsername,
|
|
|
+ "pid": browserAccountPoolUUID,
|
|
|
+ },
|
|
|
+ success: function(data){
|
|
|
+ if (data.error != undefined){
|
|
|
+ showError(data.error);
|
|
|
+ }else{
|
|
|
+ hideError();
|
|
|
+ initCurrentAccountInfo(function(){
|
|
|
+ listAllStoredAccounts();
|
|
|
+ if(ao_module_virtualDesktop){
|
|
|
+ parent.initDesktop();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
</script>
|
|
|
</body>
|
|
|
|