From 2b14046e033943a779a0dcc33a42b8166c12b0a5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 30 Mar 2017 19:36:42 +0200 Subject: Allow to login with an app token Signed-off-by: Joas Schilling --- src/components/nsNextcloud.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/components/nsNextcloud.js b/src/components/nsNextcloud.js index 269337a..02e16d7 100644 --- a/src/components/nsNextcloud.js +++ b/src/components/nsNextcloud.js @@ -37,7 +37,7 @@ Cu.import("resource:///modules/gloda/log4moz.js"); Cu.import("resource:///modules/cloudFileAccounts.js"); const kRestBase = "/ocs/v1.php"; -const kAuthPath = kRestBase + "/person/check"; +const kAuthPath = kRestBase + "/cloud/user"; const kShareApp = kRestBase + "/apps/files_sharing/api/v1/shares"; const kMaxFileSize = 1073741824; const kWebDavPath = "/remote.php/webdav"; @@ -190,7 +190,7 @@ Nextcloud.prototype = { if (!this._loggedIn) { return this._logonAndGetUserInfo(successCallback, null, true); } - + this.log.info("getting user info"); if (!this._userInfo) { @@ -398,16 +398,14 @@ Nextcloud.prototype = { this.log.info("Sending login information..."); - let username = "login=" + wwwFormUrlEncode(this._userName); - let password = "&password=" + wwwFormUrlEncode(this._password); - let loginData = username + password; let args = "?format=json"; let req = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"] .createInstance(Ci.nsIXMLHttpRequest); - req.open("POST", this._serverUrl + ":" + this._serverPort + kAuthPath + args, true); + req.open("GET", this._serverUrl + ":" + this._serverPort + kAuthPath + args, true); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); req.setRequestHeader("OCS-APIREQUEST", "true"); + req.setRequestHeader("Authorization", "Basic " + btoa(this._userName + ':' + this._password)); req.onerror = function () { this.log.info("logon failure"); @@ -447,7 +445,7 @@ Nextcloud.prototype = { } }.bind(this); - req.send(loginData); + req.send(); this.log.info("Login information sent!"); }, -- cgit v1.2.3