some fixes

This commit is contained in:
2023-06-28 02:57:57 +05:00
parent 0b1b498b7d
commit b8725f33af
11 changed files with 366 additions and 174 deletions

View File

@ -23,28 +23,28 @@ function log(nlogin,npass){
});
}
// function get_from_uuid(callback){
// const uid = $.cookie("uuid");
// const sid = $.cookie("sid");
// $.post( "/get_cr_uuid", { uuid:uid,sid:sid })
// .done(function( res ) {
// if (res["out"] == "good"){
// callback(res["body"])
// }
// else if (res["out"] == bad){
// if (res["body"] == "expired"){
// clear_ck();
// }
// }
// });
// }
function get_from_uuid(callback){
const uid = $.cookie("uuid");
const sid = $.cookie("sid");
$.post( "/get_cr_uuid", { uuid:uid,sid:sid })
.done(function( res ) {
if (res["out"] == "good"){
callback(res["body"])
}
else if (res["out"] == bad){
if (res["body"] == "expired"){
clear_ck();
}
}
});
}
function get_from_uuid(callback){
const uid = $.cookie("uuid");
const sid = $.cookie("sid");
$.post( "/get_cr_uuid", { uuid:uid,sid:sid })
.done(function( res ) {
if (res["out"] == "good"){
console.log("good");
// console.log("good");
callback(res["body"])
}
else if (res["out"] == bad){
@ -59,10 +59,10 @@ function log_by_sid() {
// const uuid = $.cookie("uuid");
// const sid = $.cookie("sid");
// console.log("log");
if($.cookie('sid') == null){
if($.cookie('uuid') == null && $.cookie('sid') == null){
// get_sid(location.hostname);
clear_ck(false);
}else{
get_sid(location.hostname);
}else if ($.cookie('sid') != null && $.cookie('uuid') != null){
$.post( "/sid_log")
.done(function( res ) {
console.log("ping");
@ -70,57 +70,59 @@ function log_by_sid() {
goto(res["url"]);
}
else if (res["out"] == "bad"){
clear_ck();
clear_ck(false);
}
})}
}
function clear_ck(redirect = true){
console.log("sid");
$.cookie("uuid",null);
$.cookie("sid",null);
get_sid(location.hostname);
if (redirect) goto("login");
$.post( "/clear_sid")
.done(function( res ) {
console.log("sid");
$.cookie("uuid",null);
$.cookie("sid",null);
$.removeCookie("uuid");
$.removeCookie('sid');
console.log("clear");
get_sid(location.hostname);
if(res["out"] == "good"){
if (redirect) goto("/login");
}
})
}
function check_sid(){
function check_sid(redirect = true){
console.log("checking sid");
if($.cookie('sid') == null || $.cookie('uuid') == null){
clear_ck();
clear_ck(redirect);
}
else{
$.post( "/sid_log")
.done(function( res ) {
if(res["out"] == "bad"){
clear_ck();
clear_ck(redirect);
}
})
}
}
function logout(quet = false) {
if (!quet)
{
let dialog = confirm("logout?");
if(dialog){
$.post( "/clear_sid")
.done(function( res ) {
if(res["out"] == "good"){
clear_ck();
}
})
}
}
else{
$.post( "/clear_sid")
.done(function( res ) {
if(res["out"] == "good"){
clear_ck();
}
})
function logout(redirect = true) {
let dialog = confirm("logout?");
if(dialog){
clear_ck(redirect);
}
}
function goto_proj(name){
$.post( "/proj/"+name, { name:hostname })
.done(function( res ) {
// if(res["out"] == "good"){
// console.log(res["body"]);
// }
});
}
function get_sid(hostname){
$.post( "/get_sid", { name:hostname })
@ -131,7 +133,15 @@ function get_sid(hostname){
});
}
function load_projs(callback){
$.post( "/get_projs")
.done(function( res ) {
if(res["out"] == "good"){
// console.log(res["body"]);
callback(res["body"]);
}
});
}
// redirect
function goto(url) {