diff options
author | Marius David Wieschollek <passwords.public@mdns.eu> | 2020-05-03 17:23:33 +0300 |
---|---|---|
committer | Marius David Wieschollek <passwords.public@mdns.eu> | 2020-05-03 17:23:33 +0300 |
commit | 333b2712b3d30a1e28af7b05c6f1c39406219ae6 (patch) | |
tree | 473cbcb1bd9957feb4139ea6b6fdea491215d751 | |
parent | b2355218b126c35f3c8e4ce7e0929c056011bc2b (diff) |
Improve passlink connect action
Signed-off-by: Marius David Wieschollek <passwords.public@mdns.eu>
-rw-r--r-- | src/PassLink/Action/Connect.js | 16 | ||||
-rw-r--r-- | src/PassLink/Action/PassLinkAction.js | 21 |
2 files changed, 36 insertions, 1 deletions
diff --git a/src/PassLink/Action/Connect.js b/src/PassLink/Action/Connect.js index ede84b3..9b27e77 100644 --- a/src/PassLink/Action/Connect.js +++ b/src/PassLink/Action/Connect.js @@ -12,6 +12,7 @@ export default class Connect extends PassLinkAction { this._codes = null; this._clientLabel = null; this._theme = null; + this._promise = null; } /** @@ -74,7 +75,20 @@ export default class Connect extends PassLinkAction { * * @return {Promise<void>} */ - async apply() { + apply() { + if(this._promise === null) { + this._promise = this._sendRequest(); + } + + return this._promise; + } + + /** + * + * @return {Promise<void>} + * @private + */ + async _sendRequest() { let url = `${this._parameters.baseUrl}index.php/apps/passwords/link/connect/apply`, request = new HttpRequest(url); diff --git a/src/PassLink/Action/PassLinkAction.js b/src/PassLink/Action/PassLinkAction.js index d73cf6c..731544d 100644 --- a/src/PassLink/Action/PassLinkAction.js +++ b/src/PassLink/Action/PassLinkAction.js @@ -3,4 +3,25 @@ export default class PassLinkAction { this._parameters = parameters; } + /** + * + * @return {Object} + */ + getParameters() { + return this._parameters; + } + + /** + * + * @param {String} name + * @return {*} + */ + getParameter(name) { + if(this._parameters.hasOwnProperty(name)) { + return this._parameters[name]; + } + + return null; + } + }
\ No newline at end of file |