Skip to content

Commit f46b00c

Browse files
committed
🚚 Rename to onAuthData
1 parent d1cfa99 commit f46b00c

File tree

8 files changed

+636
-778
lines changed

8 files changed

+636
-778
lines changed

API.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ LeanEngine 中间件会为这些 Hook 函数检查「Hook 签名」,确保调
174174
* `currentUser: AV.User`:被操作的用户。
175175
* `user: AV.User`:同 `currentUser`.
176176
* `object: AV.User`:同 `currentUser`,因为登录认证 hook 被操作的对象正好是发起操作的用户。
177-
* `authData: {[provider: string]: any}`,客户端发送的第三方登录信息(仅 `onAuthDataTransform`)。
177+
* `authData: {[provider: string]: any}`,客户端发送的第三方登录信息(仅 `onAuthData`)。
178178
179-
#### `AV.Cloud.onAuthDataTransform`
179+
#### `AV.Cloud.onAuthData`
180180
181181
这个函数的签名:`function(func: function)`,其中 `func` 是接受一个 Request 对象作为参数,返回新的 authData 的异步函数,如果抛出异常会中断第三方登录。
182182

leanengine.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export namespace Cloud {
155155

156156
export function onVerified(handler: UserHookFunction): void;
157157
export function onLogin(handler: UserHookFunction): void;
158-
export function onAuthDataTransform(handler: AuthDataTransformFunction): void;
158+
export function onAuthData(handler: AuthDataTransformFunction): void;
159159

160160
export function onIMMessageReceived(handler: CloudFunction): void;
161161
export function onIMReceiversOffline(handler: CloudFunction): void;

lib/cloud.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ Cloud.onLogin = function(func) {
161161
Cloud.define('__on_login__User', func);
162162
};
163163

164-
Cloud.onAuthDataTransform = function(func) {
165-
Cloud.define('__on_authdata_transform__User', func);
164+
Cloud.onAuthData = function(func) {
165+
Cloud.define('__on_authdata__User', func);
166166
};
167167

168168
_.each(utils.realtimeHookMapping, (metadataName, hookName) => {

lib/leanengine.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function createCloudFunctionRouter(options) {
9696
return callCloudFunction(req, functionOrClass, options);
9797
} else if (functionOrClass === 'onVerified') {
9898
return callUserHook(req, 'onVerified', hookName);
99-
} else if (functionOrClass === '_User' && _.contains(['onLogin', 'onAuthDataTransform'], hookName)) {
99+
} else if (functionOrClass === '_User' && _.contains(['onLogin', 'onAuthData'], hookName)) {
100100
return callUserHook(req, hookName, '_User');
101101
} else if ((functionOrClass === 'BigQuery' || functionOrClass === 'Insight') && hookName === 'onComplete') {
102102
return onCompleteBigQueryJob(req);
@@ -293,7 +293,7 @@ function callUserHook(req, hookName, verifyType) {
293293
}));
294294
} else {
295295
promiseTry(userHookFunction.bind(null, request)).then( result => {
296-
if (hookName === 'onAuthDataTransform') {
296+
if (hookName === 'onAuthData') {
297297
resolve({result});
298298
} else {
299299
resolve({result: 'ok'});

lib/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ exports.hookNameMapping = {
1414
afterDelete: '__after_delete_for_',
1515
onVerified: '__on_verified_',
1616
onLogin: '__on_login_',
17-
onAuthDataTransform: '__on_authdata_transform_'
17+
onAuthData: '__on_authdata_'
1818
};
1919

2020
exports.realtimeHookMapping = {

0 commit comments

Comments
 (0)