diff --git a/core/modules/syncer.js b/core/modules/syncer.js index 420e7cea9..45538e306 100644 --- a/core/modules/syncer.js +++ b/core/modules/syncer.js @@ -400,7 +400,7 @@ Syncer.prototype.handleLoginEvent = function() { var self = this; this.getStatus(function(err,isLoggedIn,username) { if(!err && !isLoggedIn) { - $tw.passwordPrompt.createPrompt({ + var promptInfo = $tw.passwordPrompt.createPrompt({ serviceName: $tw.language.getString("LoginToTiddlySpace"), callback: function(data) { self.login(data.username,data.password,function(err,isLoggedIn) { @@ -409,6 +409,10 @@ Syncer.prototype.handleLoginEvent = function() { return true; // Get rid of the password prompt } }); + // Let the sync adaptor adjust the prompt + if(self.syncadaptor && self.syncadaptor.customiseLoginPrompt) { + self.syncadaptor.customiseLoginPrompt(promptInfo); + } } }); }; diff --git a/editions/dev/tiddlers/from tw5.com/moduletypes/SyncAdaptorModules.tid b/editions/dev/tiddlers/from tw5.com/moduletypes/SyncAdaptorModules.tid index a727991a8..92f124623 100644 --- a/editions/dev/tiddlers/from tw5.com/moduletypes/SyncAdaptorModules.tid +++ b/editions/dev/tiddlers/from tw5.com/moduletypes/SyncAdaptorModules.tid @@ -1,5 +1,5 @@ created: 20130825162100000 -modified: 20200113094126878 +modified: 20201014124049248 tags: dev moduletypes title: SyncAdaptorModules type: text/vnd.tiddlywiki @@ -80,6 +80,31 @@ Attempts to login to the server with specified credentials. This method is optio |password |Password | |callback |Callback function invoked with parameter `err` | +!! `customiseLoginPrompt(promptInfo)` + +Provides an opportunity to customise the login prompt. + +|!Parameter |!Description | +|promptInfo |The `promptInfo` object returned by `$tw.passwordPrompt.createPrompt()` | + +Here's an example of customising the login prompt to include a "forgotten password" button: + +``` +SyncAdaptor.prototype.customiseLoginPrompt = function(promptInfo) { + promptInfo.form.appendChild($tw.utils.domMaker("button",{ + attributes: {type: "submit"}, + text: "Forgot password", + eventListeners: [{ + name: "click", + handlerFunction: function(event) { + promptInfo.owner.removePrompt(promptInfo); + alert("Forgot password"); + } + }] + })); +}; +``` + !! `logout(callback)` Attempts to logout of the server. This method is optional.