summaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-07-04 14:08:48 +0200
committerRobin Appelman <icewind@owncloud.com>2014-07-04 16:39:45 +0200
commitb429a716603d2d9fa60a442cde1f43d684e2afb2 (patch)
tree4550da40bf641c8eae643bd04f2c603bce57f35c /apps/files
parentb33c61798c1351dd0b1ee9a7eef0dc991a3b0167 (diff)
downloadnextcloud-server-b429a716603d2d9fa60a442cde1f43d684e2afb2.tar.gz
nextcloud-server-b429a716603d2d9fa60a442cde1f43d684e2afb2.zip
Add machine readable error messages to OC\JSON
Reload the files app in case of authentication errors, expired tokens or disabled app Reloading will triger the full server side handeling of those errors formatting fix missing semicolon + some jshint warnings
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/js/filelist.js11
-rw-r--r--apps/files/tests/js/filelistSpec.js26
2 files changed, 35 insertions, 2 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 9c6d31ee017..3e311655c91 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -947,6 +947,13 @@
this.hideMask();
if (!result || result.status === 'error') {
+ // if the error is not related to folder we're trying to load, reload the page to handle logout etc
+ if (result.data.error === 'authentication_error' ||
+ result.data.error === 'token_expired' ||
+ result.data.error === 'application_not_enabled'
+ ) {
+ OC.redirect(OC.generateUrl('apps/files'));
+ }
OC.Notification.show(result.data.message);
return false;
}
@@ -970,7 +977,7 @@
}
this.setFiles(result.data.files);
- return true
+ return true;
},
updateStorageStatistics: function(force) {
@@ -1568,7 +1575,7 @@
numMatch=base.match(/\((\d+)\)/);
var num=2;
if (numMatch && numMatch.length>0) {
- num=parseInt(numMatch[numMatch.length-1])+1;
+ num=parseInt(numMatch[numMatch.length-1], 10)+1;
base=base.split('(');
base.pop();
base=$.trim(base.join('('));
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index 713cd5468d8..ae22ae0123e 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -1933,4 +1933,30 @@ describe('OCA.Files.FileList tests', function() {
});
});
});
+ describe('Handeling errors', function () {
+ beforeEach(function () {
+ redirectStub = sinon.stub(OC, 'redirect');
+
+ fileList = new OCA.Files.FileList($('#app-content-files'));
+ });
+ afterEach(function () {
+ fileList = undefined;
+
+ redirectStub.restore();
+ });
+ it('reloads the page on authentication errors', function () {
+ fileList.reload();
+ fakeServer.requests[0].respond(
+ 200,
+ { 'Content-Type': 'application/json' },
+ JSON.stringify({
+ status: 'error',
+ data: {
+ 'error': 'authentication_error'
+ }
+ })
+ );
+ expect(redirectStub.calledWith(OC.generateUrl('apps/files'))).toEqual(true);
+ });
+ });
});