diff options
author | Joas Schilling <coding@schilljs.com> | 2017-03-30 20:36:42 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2017-03-30 20:36:42 +0300 |
commit | 2b14046e033943a779a0dcc33a42b8166c12b0a5 (patch) | |
tree | 6ec86a79f752e2dc91dba2b1a4d2a7bc54dbd6ba | |
parent | 19403f30f9f2ffaa8659151e8f6ffecc004d55bc (diff) |
Allow to login with an app token
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | src/components/nsNextcloud.js | 12 |
1 files 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!"); }, |