Skip to content

Commit 7585366

Browse files
committed
feat(user): deprecate signUpOrlogInWithAuthData[AndUnionId]
1 parent 41c979f commit 7585366

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

src/user.js

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -898,13 +898,14 @@ module.exports = function(AV) {
898898
* On success, this saves the session to disk, so you can retrieve the currently
899899
* logged in user using <code>current</code>.
900900
*
901+
* @since 3.7.0
901902
* @param {Object} authData The response json data returned from third party token, maybe like { openid: 'abc123', access_token: '123abc', expires_in: 1382686496 }
902903
* @param {string} platform Available platform for sign up.
903904
* @param {Object} [options]
904-
* @param {boolean} [options.failOnNotExist] If true, the login request will fail when no user match this authData exists.
905+
* @param {boolean} [options.failOnNotExist] If true, the login request will fail when no user matches this authData exists.
905906
* @return {Promise} A promise that is fulfilled with the user when
906907
* the login completes.
907-
* @example AV.User.signUpOrlogInWithAuthData({
908+
* @example AV.User.loginWithAuthData({
908909
* openid: 'abc123',
909910
* access_token: '123abc',
910911
* expires_in: 1382686496
@@ -915,22 +916,32 @@ module.exports = function(AV) {
915916
* });
916917
* @see {@link https://leancloud.cn/docs/js_guide.html#绑定第三方平台账户}
917918
*/
918-
signUpOrlogInWithAuthData(authData, platform, options) {
919+
loginWithAuthData(authData, platform, options) {
919920
return AV.User._logInWith(platform, authData, options);
920921
},
921922

923+
/**
924+
* @deprecated renamed to {@link AV.User.loginWithAuthData}
925+
*/
926+
signUpOrlogInWithAuthData(...param) {
927+
console.warn(
928+
'DEPRECATED: User.signUpOrlogInWithAuthData 已废弃,请使用 User#loginWithAuthData 代替'
929+
);
930+
return this.loginWithAuthData(...param);
931+
},
932+
922933
/**
923934
* Sign up or logs in a user with a third party authData and unionId.
924-
* @since 3.5.0
935+
* @since 3.7.0
925936
* @param {Object} authData The response json data returned from third party token, maybe like { openid: 'abc123', access_token: '123abc', expires_in: 1382686496 }
926937
* @param {string} platform Available platform for sign up.
927938
* @param {string} unionId
928939
* @param {Object} [unionLoginOptions]
929940
* @param {string} [unionLoginOptions.unionIdPlatform = 'weixin'] unionId platform
930941
* @param {boolean} [unionLoginOptions.asMainAccount = false] If true, the unionId will be associated with the user.
931-
* @param {boolean} [options.failOnNotExist] If true, the login request will fail when no user match this authData exists.
942+
* @param {boolean} [unionLoginOptions.failOnNotExist] If true, the login request will fail when no user matches this authData exists.
932943
* @return {Promise<AV.User>} A promise that is fulfilled with the user when completed.
933-
* @example AV.User.signUpOrlogInWithAuthDataAndUnionId({
944+
* @example AV.User.loginWithAuthDataAndUnionId({
934945
* openid: 'abc123',
935946
* access_token: '123abc',
936947
* expires_in: 1382686496
@@ -943,19 +954,30 @@ module.exports = function(AV) {
943954
* //console.error("error: ", error);
944955
* });
945956
*/
946-
signUpOrlogInWithAuthDataAndUnionId(
957+
loginWithAuthDataAndUnionId(
947958
authData,
948959
platform,
949960
unionId,
950961
unionLoginOptions
951962
) {
952-
return this.signUpOrlogInWithAuthData(
963+
return this.loginWithAuthData(
953964
mergeUnionDataIntoAuthData(authData, unionId, unionLoginOptions),
954965
platform,
955966
unionLoginOptions
956967
);
957968
},
958969

970+
/**
971+
* @deprecated renamed to {@link AV.User.loginWithAuthDataAndUnionId}
972+
* @since 3.5.0
973+
*/
974+
signUpOrlogInWithAuthDataAndUnionId(...param) {
975+
console.warn(
976+
'DEPRECATED: User.signUpOrlogInWithAuthDataAndUnionId 已废弃,请使用 User#loginWithAuthDataAndUnionId 代替'
977+
);
978+
return this.loginWithAuthDataAndUnionId(...param);
979+
},
980+
959981
/**
960982
* 使用当前使用小程序的微信用户身份注册或登录,成功后用户的 session 会在设备上持久化保存,之后可以使用 AV.User.current() 获取当前登录用户。
961983
* 仅在小程序中可用。
@@ -965,7 +987,7 @@ module.exports = function(AV) {
965987
*/
966988
loginWithWeapp() {
967989
return getWeappLoginCode().then(code =>
968-
this.signUpOrlogInWithAuthData({ code }, 'lc_weapp')
990+
this.loginWithAuthData({ code }, 'lc_weapp')
969991
);
970992
},
971993

0 commit comments

Comments
 (0)