mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-06 22:30:56 +03:00
WebClient: improve error message after the session expires
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -273,7 +273,8 @@
|
|||||||
"thursday": "Thursday",
|
"thursday": "Thursday",
|
||||||
"friday": "Friday",
|
"friday": "Friday",
|
||||||
"saturday": "Saturday",
|
"saturday": "Saturday",
|
||||||
"sunday": "Sunday"
|
"sunday": "Sunday",
|
||||||
|
"expired_session": "Your session has expired. Please log in again"
|
||||||
},
|
},
|
||||||
"fs": {
|
"fs": {
|
||||||
"view_file": "View file \"{{- path}}\"",
|
"view_file": "View file \"{{- path}}\"",
|
||||||
|
|||||||
@@ -273,7 +273,8 @@
|
|||||||
"thursday": "Giovedì",
|
"thursday": "Giovedì",
|
||||||
"friday": "Venerdì",
|
"friday": "Venerdì",
|
||||||
"saturday": "Sabato",
|
"saturday": "Sabato",
|
||||||
"sunday": "Domenica"
|
"sunday": "Domenica",
|
||||||
|
"expired_session": "La tua sessione è scaduta. Effettua nuovamente l'accesso"
|
||||||
},
|
},
|
||||||
"fs": {
|
"fs": {
|
||||||
"view_file": "Visualizza file \"{{- path}}\"",
|
"view_file": "Visualizza file \"{{- path}}\"",
|
||||||
|
|||||||
@@ -349,6 +349,8 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
|
|||||||
if (json.message) {
|
if (json.message) {
|
||||||
txt = json.message;
|
txt = json.message;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
txt = "general.expired_session";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!txt){
|
if (!txt){
|
||||||
@@ -500,6 +502,8 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
|
|||||||
let errorMessage = "";
|
let errorMessage = "";
|
||||||
if (error && error.response) {
|
if (error && error.response) {
|
||||||
switch (error.response.status) {
|
switch (error.response.status) {
|
||||||
|
case 200:
|
||||||
|
errorMessage = "general.expired_session";
|
||||||
case 403:
|
case 403:
|
||||||
errorMessage = "fs.create_dir.err_403";
|
errorMessage = "fs.create_dir.err_403";
|
||||||
break;
|
break;
|
||||||
@@ -1477,8 +1481,12 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
|
|||||||
}).then((result)=>{
|
}).then((result)=>{
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
hasError = true;
|
hasError = true;
|
||||||
|
let message = "fs.copy.err_generic";
|
||||||
|
if (result.is_redirect){
|
||||||
|
message = "general.expired_session";
|
||||||
|
}
|
||||||
ModalAlert.fire({
|
ModalAlert.fire({
|
||||||
text: $.t("fs.copy.err_generic"),
|
text: $.t(message),
|
||||||
icon: "warning",
|
icon: "warning",
|
||||||
confirmButtonText: $.t('general.ok'),
|
confirmButtonText: $.t('general.ok'),
|
||||||
customClass: {
|
customClass: {
|
||||||
@@ -1626,14 +1634,18 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
|
|||||||
}).then((result)=>{
|
}).then((result)=>{
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
hasError = true;
|
hasError = true;
|
||||||
ModalAlert.fire({
|
let message = "fs.move.err_generic";
|
||||||
text: $.t("fs.move.err_generic"),
|
if (result.is_redirect){
|
||||||
icon: "warning",
|
message = "general.expired_session";
|
||||||
confirmButtonText: $.t('general.ok'),
|
|
||||||
customClass: {
|
|
||||||
confirmButton: "btn btn-primary"
|
|
||||||
}
|
}
|
||||||
});
|
ModalAlert.fire({
|
||||||
|
text: $.t(message),
|
||||||
|
icon: "warning",
|
||||||
|
confirmButtonText: $.t('general.ok'),
|
||||||
|
customClass: {
|
||||||
|
confirmButton: "btn btn-primary"
|
||||||
|
}
|
||||||
|
});
|
||||||
} else if (result.data.length > 0){
|
} else if (result.data.length > 0){
|
||||||
hasError = true;
|
hasError = true;
|
||||||
ModalAlert.fire({
|
ModalAlert.fire({
|
||||||
@@ -1653,6 +1665,9 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
|
|||||||
KTApp.hidePageLoading();
|
KTApp.hidePageLoading();
|
||||||
let errorMessage;
|
let errorMessage;
|
||||||
switch (status) {
|
switch (status) {
|
||||||
|
case 405:
|
||||||
|
errorMessage = "general.expired_session";
|
||||||
|
break;
|
||||||
case 403:
|
case 403:
|
||||||
errorMessage = "fs.delete.err_403";
|
errorMessage = "fs.delete.err_403";
|
||||||
break;
|
break;
|
||||||
@@ -1860,8 +1875,12 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
|
|||||||
}).then((result)=>{
|
}).then((result)=>{
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
KTApp.hidePageLoading();
|
KTApp.hidePageLoading();
|
||||||
|
let message = $.t('fs.rename.err_generic', { name: oldName });
|
||||||
|
if (result.is_redirect){
|
||||||
|
message = $.t('general.expired_session');
|
||||||
|
}
|
||||||
ModalAlert.fire({
|
ModalAlert.fire({
|
||||||
text: $.t('fs.rename.err_generic', { name: oldName }),
|
text: message,
|
||||||
icon: "warning",
|
icon: "warning",
|
||||||
confirmButtonText: $.t('general.ok'),
|
confirmButtonText: $.t('general.ok'),
|
||||||
customClass: {
|
customClass: {
|
||||||
@@ -1951,6 +1970,8 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
|
|||||||
let errorMessage = "";
|
let errorMessage = "";
|
||||||
if (error && error.response) {
|
if (error && error.response) {
|
||||||
switch (error.response.status) {
|
switch (error.response.status) {
|
||||||
|
case 200:
|
||||||
|
errorMessage = "general.expired_session";
|
||||||
case 403:
|
case 403:
|
||||||
errorMessage = "fs.create_dir.err_403";
|
errorMessage = "fs.create_dir.err_403";
|
||||||
break;
|
break;
|
||||||
@@ -2100,7 +2121,11 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
|
|||||||
}).then((result)=> {
|
}).then((result)=> {
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
has_errors = true;
|
has_errors = true;
|
||||||
setI18NData($('#errorTxt'), "fs.upload.err_generic");
|
let message = "fs.upload.err_generic";
|
||||||
|
if (result.is_redirect){
|
||||||
|
message = "general.expired_session";
|
||||||
|
}
|
||||||
|
setI18NData($('#errorTxt'), message);
|
||||||
$('#errorMsg').removeClass("d-none");
|
$('#errorMsg').removeClass("d-none");
|
||||||
uploadFile();
|
uploadFile();
|
||||||
return;
|
return;
|
||||||
@@ -2163,13 +2188,16 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
|
|||||||
return status == 200;
|
return status == 200;
|
||||||
}
|
}
|
||||||
}).then(function(response){
|
}).then(function(response){
|
||||||
|
let isJsonResponse = response.headers['content-type'] === 'application/json'
|
||||||
promiseResolve({
|
promiseResolve({
|
||||||
error: false,
|
error: !isJsonResponse,
|
||||||
|
is_redirect: !isJsonResponse,
|
||||||
data: response.data
|
data: response.data
|
||||||
});
|
});
|
||||||
}).catch(function(error){
|
}).catch(function(error){
|
||||||
promiseResolve({
|
promiseResolve({
|
||||||
error: true
|
error: true,
|
||||||
|
is_redirect: false
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user