Skip to content

Commit abcd934

Browse files
committed
docs(user): update OAuth login method definitions
and fix some definition issues.
1 parent 9bd5224 commit abcd934

File tree

2 files changed

+54
-38
lines changed

2 files changed

+54
-38
lines changed

src/user.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,6 @@ module.exports = function(AV) {
644644
/**
645645
* Calls set("mobilePhoneNumber", phoneNumber, options) and returns the result.
646646
* @param {String} mobilePhoneNumber
647-
* @param {AuthOptions} options
648647
* @return {Boolean}
649648
* @see AV.Object#set
650649
*/
@@ -655,7 +654,6 @@ module.exports = function(AV) {
655654
/**
656655
* Calls set("username", username, options) and returns the result.
657656
* @param {String} username
658-
* @param {AuthOptions} options
659657
* @return {Boolean}
660658
* @see AV.Object#set
661659
*/
@@ -666,7 +664,6 @@ module.exports = function(AV) {
666664
/**
667665
* Calls set("password", password, options) and returns the result.
668666
* @param {String} password
669-
* @param {AuthOptions} options
670667
* @return {Boolean}
671668
* @see AV.Object#set
672669
*/
@@ -799,8 +796,8 @@ module.exports = function(AV) {
799796
*
800797
* @param {String} username The username (or email) to sign up with.
801798
* @param {String} password The password to sign up with.
802-
* @param {Object} attrs Extra fields to set on the new user.
803-
* @param {AuthOptions} options
799+
* @param {Object} [attrs] Extra fields to set on the new user.
800+
* @param {AuthOptions} [options]
804801
* @return {Promise} A promise that is fulfilled with the user when
805802
* the signup completes.
806803
* @see AV.User#signUp
@@ -820,15 +817,14 @@ module.exports = function(AV) {
820817
*
821818
* @param {String} username The username (or email) to log in with.
822819
* @param {String} password The password to log in with.
823-
* @param {AuthOptions} options
824820
* @return {Promise} A promise that is fulfilled with the user when
825821
* the login completes.
826822
* @see AV.User#logIn
827823
*/
828-
logIn: function(username, password, options) {
824+
logIn: function(username, password) {
829825
var user = AV.Object._create('_User');
830826
user._finishFetch({ username: username, password: password });
831-
return user.logIn(options);
827+
return user.logIn();
832828
},
833829

834830
/**
@@ -869,15 +865,14 @@ module.exports = function(AV) {
869865
*
870866
* @param {String} mobilePhone The user's mobilePhoneNumber
871867
* @param {String} smsCode The sms code sent by AV.User.requestLoginSmsCode
872-
* @param {AuthOptions} options
873868
* @return {Promise} A promise that is fulfilled with the user when
874869
* the login completes.
875870
* @see AV.User#logIn
876871
*/
877-
logInWithMobilePhoneSmsCode: function(mobilePhone, smsCode, options) {
872+
logInWithMobilePhoneSmsCode: function(mobilePhone, smsCode) {
878873
var user = AV.Object._create('_User');
879874
user._finishFetch({ mobilePhoneNumber: mobilePhone, smsCode: smsCode });
880-
return user.logIn(options);
875+
return user.logIn();
881876
},
882877

883878
/**
@@ -914,18 +909,17 @@ module.exports = function(AV) {
914909
*
915910
* @param {String} mobilePhone The user's mobilePhoneNumber
916911
* @param {String} password The password to log in with.
917-
* @param {AuthOptions} options
918912
* @return {Promise} A promise that is fulfilled with the user when
919913
* the login completes.
920914
* @see AV.User#logIn
921915
*/
922-
logInWithMobilePhone: function(mobilePhone, password, options) {
916+
logInWithMobilePhone: function(mobilePhone, password) {
923917
var user = AV.Object._create('_User');
924918
user._finishFetch({
925919
mobilePhoneNumber: mobilePhone,
926920
password: password,
927921
});
928-
return user.logIn(options);
922+
return user.logIn();
929923
},
930924

931925
/**

storage.d.ts

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -545,11 +545,17 @@ export class Role extends Object {
545545
setName(name: string): Role;
546546
}
547547

548-
interface UnionLoginOptions {
548+
interface OAuthLoginOptions {
549+
failOnNotExist?: boolean;
550+
}
551+
552+
interface UnionOptions {
549553
unionIdPlatform?: string;
550554
asMainAccount?: boolean;
551555
}
552556

557+
interface UnionLoginOptions extends OAuthLoginOptions, UnionOptions {}
558+
553559
/**
554560
* @class
555561
*
@@ -561,35 +567,41 @@ interface UnionLoginOptions {
561567
*/
562568
export class User extends Object {
563569
static current(): User;
570+
static currentAsync(): Promise<User>;
564571
static signUp(
565572
username: string,
566573
password: string,
567-
attrs: any,
568-
options?: AuthOptions
569-
): Promise<User>;
570-
static logIn(
571-
username: string,
572-
password: string,
574+
attrs?: any,
573575
options?: AuthOptions
574576
): Promise<User>;
577+
static logIn(username: string, password: string): Promise<User>;
575578
static logOut(): Promise<User>;
576-
static become(sessionToken: string, options?: AuthOptions): Promise<User>;
579+
static become(sessionToken: string): Promise<User>;
577580

578-
static loginWithWeapp(): Promise<User>;
581+
static loginWithWeapp(options?: OAuthLoginOptions): Promise<User>;
579582
static logInWithMobilePhone(
580583
mobilePhone: string,
581-
password: string,
582-
options?: AuthOptions
584+
password: string
583585
): Promise<User>;
584586
static logInWithMobilePhoneSmsCode(
585587
mobilePhone: string,
586-
smsCode: string,
587-
options?: AuthOptions
588+
smsCode: string
589+
): Promise<User>;
590+
static loginWithAuthData(
591+
authData: Object,
592+
platform: string,
593+
options?: OAuthLoginOptions
588594
): Promise<User>;
589595
static signUpOrlogInWithAuthData(
590-
data: any,
596+
authData: Object,
591597
platform: string,
592-
options?: AuthOptions
598+
options?: OAuthLoginOptions
599+
): Promise<User>;
600+
static loginWithAuthDataAndUnionId(
601+
authData: Object,
602+
platform: string,
603+
unionId: string,
604+
unionLoginOptions?: UnionLoginOptions
593605
): Promise<User>;
594606
static signUpOrlogInWithAuthDataAndUnionId(
595607
authData: Object,
@@ -633,8 +645,21 @@ export class User extends Object {
633645
static followerQuery(userObjectId: string): FriendShipQuery;
634646
static followeeQuery(userObjectId: string): FriendShipQuery;
635647

648+
loginWithWeapp(options?: OAuthLoginOptions): Promise<User>;
649+
loginWithAuthData(
650+
authData: Object,
651+
platform: string,
652+
options?: OAuthLoginOptions
653+
): Promise<User>;
654+
loginWithAuthDataAndUnionId(
655+
authData: Object,
656+
platform: string,
657+
unionId: string,
658+
unionLoginOptions?: UnionLoginOptions
659+
): Promise<User>;
660+
636661
signUp(attrs?: any, options?: AuthOptions): Promise<User>;
637-
logIn(options?: AuthOptions): Promise<User>;
662+
logIn(): Promise<User>;
638663
linkWithWeapp(): Promise<User>;
639664
isAuthenticated(): Promise<boolean>;
640665
isCurrent(): boolean;
@@ -644,23 +669,20 @@ export class User extends Object {
644669
authData: Object,
645670
platform: string,
646671
unionId: string,
647-
unionLoginOptions?: UnionLoginOptions
672+
unionLoginOptions?: UnionOptions
648673
): Promise<User>;
649674
dissociateAuthData(platform: string): Promise<User>;
650675

651676
getEmail(): string;
652-
setEmail(email: string, options?: AuthOptions): boolean;
677+
setEmail(email: string): boolean;
653678

654-
setMobilePhoneNumber(
655-
mobilePhoneNumber: string,
656-
options?: AuthOptions
657-
): boolean;
679+
setMobilePhoneNumber(mobilePhoneNumber: string): boolean;
658680
getMobilePhoneNumber(): string;
659681

660682
getUsername(): string;
661-
setUsername(username: string, options?: AuthOptions): boolean;
683+
setUsername(username: string): boolean;
662684

663-
setPassword(password: string, options?: AuthOptions): boolean;
685+
setPassword(password: string): boolean;
664686
getSessionToken(): string;
665687
refreshSessionToken(options?: AuthOptions): Promise<User>;
666688

0 commit comments

Comments
 (0)