我正在使用 FatFractal JavaScript SDK,并在我的 FFDL 文件中声明了一个服务器扩展,如下所示:
CREATE EXTENSION /ChangePassword AS javascript:require('scripts/UserAdministration').changePassword();
我正在创建一个服务器扩展以允许用户更改他们的登录密码。从我的客户端应用程序中,我想传递一个简单的对象来/ChangePassword
包含登录用户的用户名、当前(旧)密码和新的所需密码。假设我已经填充了所述对象,那么我将如何 A)将客户端应用程序的对象传递给服务器扩展,B)获取服务器扩展中传递的对象的句柄,以及 C)返回确认对象(最好)或消息更改完成后从服务器扩展到客户端应用程序?
FFDL:
CREATE OBJECTTYPE ChangePasswordRequest (userName STRING, oldPassword STRING, newPassword STRING)
CREATE COLLECTION /ChangePasswordRequest OBJECTTYPE ChangePasswordRequest
客户端应用JS代码:
...
function ChangePassInfo() {
this.userName = null;
this.currentPassword = null;
this.newPassword = null;
return this;
}
...
function changePassword() {
var uname = ff.loggedInUser().userName;
var oldPass = $("#input-curr-pass").val();
var newPass = $("#input-new-pass").val();
var requestInfo = new ChangePassInfo();
requestInfo.userName = uname;
requestInfo.currentPassword = oldPass;
requestInfo.newPassword = newPass;
// pass 'requestInfo' to 'ChangePassword' extension
// acquire handle to confirmation object/message returned from 'ChangePassword'
...
}
服务器扩展JS代码:
var ff = require('ffef/FatFractal');
...
function ChangePasswordRequest() {
this.clazz = 'ChangePasswordRequest';
this.createdBy = 'system';
this.userName = null;
this.oldPassword = null;
this.newPassword = null;
return this;
}
...
function changePassword() {
var changePassReq; // instance of a 'ChangePasswordRequest' object
// acquire handle to 'requestInfo' passed from client application to populate 'changePassReq'
...
// return a confirmation message or copy of 'changePassReq' to client application
}
...
exports.changePassword = changePassword;
评论部分是我要解决的问题领域。一旦这些都解决了,我应该能够填写其余的实现。谢谢!