Skip to content

Commit 3108614

Browse files
committed
Merge branch 'SK8-PTY-LTD-master'
2 parents 67f331e + 91a9c95 commit 3108614

File tree

2 files changed

+240
-181
lines changed

2 files changed

+240
-181
lines changed

lib/user.js

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ module.exports = function(AV) {
359359
});
360360
})._thenRunCallbacks(options, this);
361361
},
362-
363362
/**
364363
* @see AV.Object#save
365364
*/
@@ -732,6 +731,43 @@ module.exports = function(AV) {
732731
return user.logIn(options);
733732
},
734733

734+
/**
735+
* Sign up or logs in a user with a third party auth data(AccessToken).
736+
* On success, this saves the session to disk, so you can retrieve the currently
737+
* logged in user using <code>current</code>.
738+
*
739+
* <p>Calls options.success or options.error on completion.</p>
740+
*
741+
* @param {Object} data The response json data returned from third party token.
742+
* @param {string} platform Available platform for sign up.
743+
* @param {Object} [callback] An object that has an optional success function, that takes no arguments and will be called on a successful puSH. and an error function that takes a AV.Error and will be called if the push failed.
744+
* @return {AV.Promise} A promise that is fulfilled with the user when
745+
* the login completes.
746+
* @example AV.User.signUpOrlogInWithAuthData(data, platform, {
747+
* success: function(user) {
748+
* //Access user here
749+
* },
750+
* error: function(error) {
751+
* //console.log("error: ", error);
752+
* }
753+
* });
754+
* @see {@link https://leancloud.cn/docs/js_guide.html#绑定第三方平台账户}
755+
*/
756+
signUpOrlogInWithAuthData: function (data, platform, callback) {
757+
/**
758+
* Construct accessToken
759+
*/
760+
return AV.User._logInWith(platform, {
761+
"authData": data,
762+
success: function (user) {
763+
callback.success(user);
764+
},
765+
error: function (error) {
766+
callback.error(error);
767+
}
768+
});
769+
},
770+
735771
/**
736772
* Logs out the currently logged in user session. This will remove the
737773
* session from disk, log out of linked services, and future calls to

0 commit comments

Comments
 (0)